Skip to content

Retry transient upstream errors in snippet and LOC generation#8425

Merged
iHiD merged 1 commit into
mainfrom
fix/8396
Feb 9, 2026
Merged

Retry transient upstream errors in snippet and LOC generation#8425
iHiD merged 1 commit into
mainfrom
fix/8396

Conversation

@iHiD
Copy link
Copy Markdown
Member

@iHiD iHiD commented Feb 8, 2026

Closes #8396

Summary

  • Rescue RestClient::BadGateway (502), ServiceUnavailable (503), and GatewayTimeout (504) in Iteration::GenerateSnippet and Iteration::CountLinesOfCode
  • Requeue the job up to 3 times with a random 30-90 second delay using self.class.defer with a retries_count kwarg
  • After retries are exhausted, the exception propagates to Sidekiq/Sentry so persistent failures are still surfaced
  • Uses initialize_with :iteration, retries_count: 0 to track retry count across requeues

Test plan

  • Added tests for requeue on BadGateway, ServiceUnavailable, and GatewayTimeout (GenerateSnippet)
  • Added test for requeue on BadGateway (CountLinesOfCode)
  • Added tests verifying exception re-raises after max retries exhausted (both commands)
  • All 20 tests pass: bundle exec rails test test/commands/iteration/generate_snippet_test.rb test/commands/iteration/count_lines_of_code_test.rb

🤖 Generated with Claude Code

Rescue 502/503/504 errors from the snippet generator and lines-of-code
counter services, requeuing the job up to 3 times with a random delay.
After retries are exhausted, the exception propagates to Sidekiq/Sentry
so persistent failures are still surfaced.

Closes #8396

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@iHiD iHiD merged commit a32503a into main Feb 9, 2026
41 checks passed
@iHiD iHiD deleted the fix/8396 branch February 9, 2026 10:14
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.

RestClient::BadGateway: 502 Bad Gateway (RestClient::BadGateway)

1 participant