Skip to content

fix: replace bare except clauses with specific exception types#5066

Open
mango766 wants to merge 1 commit into1Panel-dev:v2from
mango766:fix/bare-except-catches-keyboard-interrupt
Open

fix: replace bare except clauses with specific exception types#5066
mango766 wants to merge 1 commit into1Panel-dev:v2from
mango766:fix/bare-except-catches-keyboard-interrupt

Conversation

@mango766
Copy link
Copy Markdown

@mango766 mango766 commented Apr 9, 2026

Summary

Fixes #5065

Replace bare except: clauses with specific exception types to prevent catching KeyboardInterrupt and SystemExit, which can prevent proper Celery worker shutdown and cause processes to hang.

Changes

  • apps/ops/celery/utils.py: Changed except: to except (ValueError, AttributeError): in UUID validation (uuid.UUID() raises ValueError on invalid input)
  • apps/application/flow/step_node/tool_node/impl/base_tool_node.py: Changed except: to except (json.JSONDecodeError, TypeError, ValueError): in type validation (json.loads() raises JSONDecodeError on invalid JSON)

Test plan

  • Verify UUID validation still correctly rejects invalid task IDs
  • Verify tool node type validation still correctly handles invalid JSON input
  • Verify Celery worker can be cleanly shut down with SIGINT

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 1Panel-dev#5065

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot bot commented Apr 9, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot bot commented Apr 9, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: bare except clauses catch KeyboardInterrupt and SystemExit

1 participant