From baa360d54f68001b594a0689f0d2f3b9ad31c806 Mon Sep 17 00:00:00 2001 From: Andrew Pollock Date: Tue, 6 Aug 2024 15:27:29 +1000 Subject: [PATCH] Don't crash on an UnexpectedSituation (#2453) Rather than crash and prematurely end an invocation with potentially more bugs left to process, gracefully handle `UnexpectedSituation` exceptions and continue processing the rest of the bugs. Necessary because there are still some Git-sourced CVEs in Datastore that require reimporting from GCS, and tickle this edge case. --- tools/datafix/reimport_gcs_record.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/datafix/reimport_gcs_record.py b/tools/datafix/reimport_gcs_record.py index a90380dad65..4ce7233dbc5 100755 --- a/tools/datafix/reimport_gcs_record.py +++ b/tools/datafix/reimport_gcs_record.py @@ -171,7 +171,12 @@ def main() -> None: try: with ds_client.transaction() as xact: for bug in result_to_fix: - bug_in_gcs = objname_for_bug(ds_client, bug) + try: + bug_in_gcs = objname_for_bug(ds_client, bug) + except UnexpectedSituation as e: + if args.verbose: + print(f"Skipping {bug['db_id']}, got {e}\n") + continue if args.verbose: print(f"Resetting creation time for {bug_in_gcs['uri']}") if not args.dryrun: