fix: limit retriable hook status codes#443
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe PR modifies webhook retry logic in the gotrue authentication service to improve resilience. The implementation layer introduces exponential backoff delays before each retry attempt and classifies HTTP responses into retriable (429, 5xx) and non-retriable categories. Non-retriable responses immediately return an error, while retriable responses continue the retry loop. The test layer validates this behavior with three test cases: one confirming retriable 503 responses retry until success, one confirming non-retriable 400 responses fail immediately, and one confirming 429 responses retry until success. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@api/hooks.go`:
- Around line 142-148: The response body (rsp.Body) isn't closed on the failure
paths: ensure you explicitly close the response before retrying or
returning—i.e., before the "continue" for retriable responses and before the
"return" for non-retriable responses in the webhook handling block; call
rsp.Body.Close() (guarding for non-nil) and optionally drain the body
(io.Copy(ioutil.Discard, rsp.Body)) to reuse connections, instead of deferring
inside the loop. This change touches the webhook response handling logic around
the rsp variable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 244c8307-6aa4-4c4d-add3-4d285605ad91
📒 Files selected for processing (2)
api/hook_test.goapi/hooks.go
ndhoule
left a comment
There was a problem hiding this comment.
Looks great! Thanks very much for these fixes ❤️
Stop retrying hook calls on status codes other than 429 and 5xx. Also adds a basic backoff.