fix(integration-discord): handle 429 rate limits#334
Conversation
Add retry logic with jittered backoff (3-6s) to purge-invites, preventing Cloudflare IP bans. Extract DTOs for purge result and matched invite.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
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
`@app-modules/integration-discord/src/Sync/Actions/PurgeUnusedInvitesAction.php`:
- Around line 64-67: The array_filter function preserves original keys, which
means the first remaining invite in the $unused array may have an index greater
than 0, causing the condition at line 65 ($index > 0) to trigger unnecessarily
on the first invite and cause an unwanted sleep. Before iterating over $unused
in the foreach loop within PurgeUnusedInvitesAction, apply array_values() to
reindex the filtered invites array with consecutive numeric keys starting from
0, ensuring that only invites after the first one will have $index > 0 and
trigger the jitteredSleep().
🪄 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: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 85fb8d48-9423-4237-b969-94b5f3c76466
📒 Files selected for processing (5)
app-modules/integration-discord/src/Sync/Actions/PurgeUnusedInvitesAction.phpapp-modules/integration-discord/src/Sync/Console/PurgeUnusedInvitesCommand.phpapp-modules/integration-discord/src/Sync/DTOs/MatchedInviteDTO.phpapp-modules/integration-discord/src/Sync/DTOs/PurgeInvitesResultDTO.phpapp-modules/integration-discord/tests/Unit/Sync/PurgeUnusedInvitesActionTest.php
array_filter preserves keys, causing a spurious sleep before the first delete when index > 0.
Summary
purge-invitescommand, respecting Discord'sretry_afterheader on 429 responsesPurgeInvitesResultDTOandMatchedInviteDTOfrom raw array returns, withfromDiscordApi(),fromDryRun(), andfromPurge()factory methodsTest plan