Clean up exception handling in schedulers and models#5689
Clean up exception handling in schedulers and models#5689yashhzd wants to merge 1 commit intoOWASP-BLT:mainfrom
Conversation
- models.py: replace bare except: with except Exception: in validate_image to avoid catching SystemExit/KeyboardInterrupt - run_daily.py: remove unused `as e` from 10 except clauses where exc_info=True is used instead (ruff F841) - run_hourly.py: remove unused `as e`, use logger.exception for consistent traceback logging - run_monthly.py: same as run_hourly - run_ten_minutes.py: remove unused `as e` from 2 except clauses
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
|
👋 Hi @yashhzd! This pull request needs a peer review before it can be merged. Please request a review from a team member who is not:
Once a valid peer review is submitted, this check will pass automatically. Thank you! |
📊 Monthly LeaderboardHi @yashhzd! Here's how you rank for February 2026:
Scoring this month: Open PRs (+1 each), Merged PRs (+10), Closed (not merged) (−2), Reviews (+5; first two per PR in-month), Comments (+2, excludes CR). Coderabbit chats column is visible. Points per chat: 0; daily cap per user (UTC): 7. |
Clean up exception handling in schedulers and models
Changes
1. Bare
except:invalidate_image(models.py)The image validator uses bare
except:which catchesSystemExitandKeyboardInterrupt. Changed toexcept Exception:.2. Unused
as evariables in scheduler commandsAll four scheduler commands (
run_daily,run_hourly,run_monthly,run_ten_minutes) catch exceptions withas ebut never use theevariable — they useexc_info=Trueor f-string formatting instead. This triggers ruff F841 (unused variable).run_daily.py — 10 occurrences of
except Exception as e:whereeis unusedrun_hourly.py — 1 occurrence, also switched from
f"Error: {e}"tologger.exception()for consistent traceback loggingrun_monthly.py — 1 occurrence, same improvement
run_ten_minutes.py — 2 occurrences
Why this matters
except:prevents graceful process shutdown (catchesSystemExit,KeyboardInterrupt)as eis a lint warning that clutters code and signals intent to use the variable when it's actually ignoredlogger.exception()automatically includes the traceback, makingas e+f"{e}"redundant