Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(integrations): Check retries_left before capturing exception #3803

Conversation

malkovro
Copy link
Contributor

@malkovro malkovro commented Nov 19, 2024

Since rq/rq#1964 the job status is set to Failed before the handler decides whether to capture or not the exception while handle_job_failure has not yet been called so the job is not yet re-scheduled leading to all exceptions getting captured in RQ version >= 2.0.

Related to #1076
Fixes #3707

@sentrivana sentrivana added the Trigger: tests using secrets PR code is safe; run CI label Nov 19, 2024
Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @malkovro!

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.90%. Comparing base (01146bd) to head (81a7f71).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3803      +/-   ##
==========================================
+ Coverage   79.87%   79.90%   +0.03%     
==========================================
  Files         137      137              
  Lines       15371    15373       +2     
  Branches     2608     2608              
==========================================
+ Hits        12277    12284       +7     
+ Misses       2223     2221       -2     
+ Partials      871      868       -3     
Files with missing lines Coverage Δ
sentry_sdk/integrations/rq.py 82.55% <100.00%> (+0.41%) ⬆️

... and 3 files with indirect coverage changes

Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to make this compatible with older rq versions where the jobs don't have the retries_left attribute, see here: https://github.com/getsentry/sentry-python/actions/runs/11915419148/job/33205698444?pr=3803

Should hopefully be a small change, maybe we can use getattr and make sure if the property is not there, the behavior remains the same as before this change.

@malkovro malkovro force-pushed the fix/rq-integration-ignore-retryable-exceptions branch from f4fdbb5 to 2754747 Compare November 19, 2024 15:24
@github-actions github-actions bot removed the Trigger: tests using secrets PR code is safe; run CI label Nov 19, 2024
Bring back compatibility across rq versions

Fixes GH-3707
@malkovro malkovro force-pushed the fix/rq-integration-ignore-retryable-exceptions branch from 2754747 to 30e8044 Compare November 19, 2024 15:25
Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, ty!

@sentrivana sentrivana enabled auto-merge (squash) November 19, 2024 15:37
@sentrivana sentrivana added the Trigger: tests using secrets PR code is safe; run CI label Nov 19, 2024
@sentrivana sentrivana merged commit 3e28853 into getsentry:master Nov 19, 2024
137 of 139 checks passed
@malkovro malkovro deleted the fix/rq-integration-ignore-retryable-exceptions branch November 19, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Trigger: tests using secrets PR code is safe; run CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RQ 2.0 breaks a test
2 participants