Repository navigation
fix(api): answer 4xx for bad approval tokens and a missing revoke execution - #584
Conversation
…cution Invalid approval tokens now answer 403, expired tokens 410, and a non-pending execution in token mode 409 on approve and cancel. Revoke by email answers 404 for a missing execution. Closes #564.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour. 📝 WalkthroughWalkthroughPurchase approval and cancellation handlers now map invalid tokens, expired tokens, and execution-status conflicts to client error responses. Email revocation returns 404 for a missing execution. Handler tests and OpenAPI response descriptions cover these outcomes. ChangesPurchase token error responses
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The described token-mode response changes have no identified merge-blocking issue. Normal checks remain appropriate. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation [Issue Full details: Docstring CoverageExplanation Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Reword a comment the misspell linter flagged, add a test for the cancel CAS-loss mapping, and note in openapi that the delayed-approval path does not validate the token yet.
Summary
purchaseexposesErrInvalidApprovalTokenandErrApprovalTokenExpired; the cancel path reusesvalidateApprovalTokeninstead of a duplicate copy of the checks.POST /api/purchases/revoke/{id}(email revoke) answers 404 for a missing execution instead of 500.Scope: token mode only. Session-mode approve/direct-execute status mapping stays with #532.
Known limits, deliberately not changed here:
approveWithDelay) does not validate the token yet; tracked separately.validateRevokeToken(403 invalid, 409 expired) and the RI exchange token path are unchanged, so expired-token codes are inconsistent for now (410 on approve/cancel, 409 on revoke). Alignment is a follow-up.Test plan
Closes #564
Summary by CodeRabbit
Bug Fixes
Documentation