Repository navigation
fix/RR-1023-duplicate-discussion-sync - #1027
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR fixes a critical bug in the Discord discussions workflow where edited discussions post new messages instead of updating existing ones. The fix normalizes the webhook URL into a reusable ChangesDiscord webhook URL normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
No description provided. |
|
Actionable comments posted: 0 |
anandray
left a comment
There was a problem hiding this comment.
LGTM — textbook implementation of #1023's prescribed fix.
BASE="${DISCORD_WEBHOOK_URL%%\?*}" + BASE="${BASE%/}" correctly normalizes against both query strings (?thread_id=...) and trailing slashes. All four URL-construction sites consistently use $BASE (PATCH on marker hit, POST create, DELETE race-guard, PATCH race-guard re-apply), and the old WEBHOOK_ID/WEBHOOK_TOKEN awk-split is fully retired. --no-retry-5xx on POST is the right at-most-once posture given the discord-helper contract (only 429 is replay-safe).
In-file comments accurately document the cascade. CI green, no CR threads. Local-against-throwaway-webhook verification covers the 5 URL shapes that would have triggered the bug.
…ocketride-org#1027) Co-authored-by: EdwardLien0426 <pohsu.lien@rocketride.ai>
Closes #1023
Root cause
POST used the raw
DISCORD_DISCUSSIONS_WEBHOOK_URL; PATCH rebuilt the URL viaawk -F'/'over the same secret. Any deviation fromhttps://discord.com/api/webhooks/{id}/{token}— trailing slash,?thread_id=..., alternate host — silently breaks the PATCH target while POST keeps working.Cascade
Malformed PATCH → Discord 404 → handler treats it as "message deleted" → deletes the marker comment → falls through to POST → posts a fresh message + writes a new marker → next edit hits the same broken PATCH again. Repost on every update.
(Local repro with a trailing-slash webhook returns 405 rather than 404; in that shape the job would
exit 1instead of reposting. Whichever shape prod actually sees, the URL is malformed and this PR eliminates both failure modes.)Fix
$BASE(strip query string + trailing slash). Reuse$BASEfor the marker-hit PATCH, the create POST, and the race-guard DELETE + PATCH.--no-retry-5xx -X POSTto the create call per thediscord-helpercontract. Without it a transient Discord 5xx could create a duplicate message on retry — a second, independent duplicate source fixed in the same PR.Verification
Local-only; final acceptance needs a
developmerge + a real discussion edit.${URL%%\?*}+${BASE%/}tested against canonical, trailing-slash,?thread_id=, combined, anddiscordapp.comshapes — all produce a clean base.$BASE: 200 (message edited in place, no duplicate)bash -non the inline script passes.Acceptance criteria
Summary by CodeRabbit
Bug Fixes
Chores