Skip to content

Commit 1f9517f

Browse files
easonysliuclaude
andcommitted
fix: replace bare except clauses with specific exception types
Bare `except:` clauses catch KeyboardInterrupt and SystemExit, which prevents proper Celery worker shutdown and can cause processes to hang. - `utils.py`: uuid.UUID() raises ValueError on invalid input, so catch (ValueError, AttributeError) instead of bare except - `base_tool_node.py`: json.loads() raises JSONDecodeError on invalid JSON, so catch (json.JSONDecodeError, TypeError, ValueError) instead Fixes #5065 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5bca299 commit 1f9517f

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

apps/application/flow/step_node/tool_node/impl/base_tool_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def valid_reference_value(_type, value, name):
5151
raise Exception(_(
5252
'Field: {name} Type: {_type} Value: {value} Unsupported types'
5353
).format(name=name, _type=_type))
54-
except:
54+
except (json.JSONDecodeError, TypeError, ValueError):
5555
return value
5656
if not isinstance(value, instance_type):
5757
raise Exception(_(

apps/ops/celery/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_task_log_path(base_path, task_id, level=2):
4242
task_id = str(task_id)
4343
try:
4444
uuid.UUID(task_id)
45-
except:
45+
except (ValueError, AttributeError):
4646
return os.path.join(PROJECT_DIR, 'data', 'caution.txt')
4747

4848
rel_path = os.path.join(*task_id[:level], task_id + '.log')

0 commit comments

Comments
 (0)