Skip to content

Commit

Permalink
#androidenv Fix broad exception in task_manager.py
Browse files Browse the repository at this point in the history
This CL changes the broad exception to a list of specific exceptions that are likely to occur when parsing extras.

PiperOrigin-RevId: 676946964
  • Loading branch information
DeepMind authored and copybara-github committed Sep 20, 2024
1 parent cf08e17 commit 60cf5ad
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion android_env/components/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,13 @@ def _extras_handler(event, match):
try:
extra = ast.literal_eval(extra)
# Except all to avoid unnecessary crashes, only log error.
except Exception: # pylint: disable=broad-except
except (
ValueError,
TypeError,
SyntaxError,
MemoryError,
RecursionError,
):
logging.exception('Could not parse extra: %s', extra)
# Don't try to process the extra as text; that would probably crash.
return
Expand Down

0 comments on commit 60cf5ad

Please sign in to comment.