Skip to content

fix: replace bare except with except Exception in tool scripts#16371

Open
harshadkhetpal wants to merge 2 commits intoansible:develfrom
harshadkhetpal:fix/bare-except-scripts
Open

fix: replace bare except with except Exception in tool scripts#16371
harshadkhetpal wants to merge 2 commits intoansible:develfrom
harshadkhetpal:fix/bare-except-scripts

Conversation

@harshadkhetpal
Copy link

@harshadkhetpal harshadkhetpal commented Mar 25, 2026

Summary

Replace bare except: clauses with except Exception: in two tool scripts (3 occurrences total).

Bare except: catches SystemExit, KeyboardInterrupt, and GeneratorExit in addition to regular exceptions, which can mask critical signals.

Files changed:

  • tools/scripts/config-watcher — 2 bare except clauses (lines 39, 57)
  • tools/scripts/post_webhook.py — 1 bare except clause (line 131)

Change:

# Before
        except:

# After
        except Exception:

Testing

No behavior change for normal exceptions — style/correctness fix only.
Prevents accidentally catching SystemExit and KeyboardInterrupt.

Summary by CodeRabbit

  • Chores
    • Enhanced exception handling robustness in internal utility scripts.

@coderabbitai
Copy link

coderabbitai bot commented Mar 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0f80383b-9d23-4db4-8aad-b5ee3bed4b61

📥 Commits

Reviewing files that changed from the base of the PR and between 310dd3e and 4e860a5.

📒 Files selected for processing (2)
  • tools/scripts/config-watcher
  • tools/scripts/post_webhook.py

📝 Walkthrough

Walkthrough

Two Python scripts in tools/scripts/ were updated to replace bare except: clauses with except Exception:. The config-watcher script had two such clauses narrowed (around hash computation and comparison logic), while post_webhook.py had one narrowed (around JSON parsing). No control flow or behavior changes result from these modifications.

Changes

Cohort / File(s) Summary
Exception Handling Narrowing
tools/scripts/config-watcher, tools/scripts/post_webhook.py
Replaced bare except: clauses with except Exception: to catch only standard exception types rather than all catchable errors, improving exception specificity without altering existing error handling or control flow.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing bare except clauses with except Exception across multiple tool scripts.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant