Skip to content

fix(approval): stop telling permanent 403/404 details failures to retry - #548

Merged
cristim merged 2 commits into
mainfrom
fix/approval-link-details-529
Oct 5, 2026
Merged

cristim merged 2 commits into
mainfrom
fix/approval-link-details-529

Conversation

@cristim

@cristim cristim commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

What

When the approval details fetch fails with 403 or 404, the approval-link toast no longer says "Open the approval link again to retry". 403 now says loading details requires the view:purchases permission and access to the purchase's account. 404 says the purchase was not found or is outside your account access (getPurchaseDetails returns 404 both for a missing execution and for an out-of-scope one). Both keep the server's error message in the text. 401, 5xx and network errors keep the retry wording.

History is untouched (history.ts is identical to main). A separate wording for History is not needed because GET /api/history already requires view:purchases (internal/api/handler_history.go:21).

Why

Since #497 the approval modal refuses to open when the details fetch fails. For an approver without access, 403/404 is permanent, so the retry advice can never work. This is the toast half of #529.

Not done (deliberately)

The backend half (a token-authorised details read) is not implemented, so #529 stays open (Refs):

  • The suggested route GET /api/purchases/approve/{id} is already the side-effecting token approve (internal/api/router.go:163).
  • validateApprovalToken is unexported (internal/purchase/approvals.go:111), so a read bound to the token would need it exported.
  • getPurchaseDetails returns more than the modal needs.
    A new authorization surface is parked as an owner decision.

Verification

  • jest, full frontend suite: 93 suites passed, 3066 tests passed, 1 skipped (3067 total). tsc --noEmit exit 0. eslint exit 0 (0 errors, 125 existing warnings).
  • purchases-deeplink.test.ts covers 403, 404 (permanent, server message kept, no retry text) and 500, 401, network error (retry path kept). Mutation checks: dropping 403, dropping 404, treating 5xx as permanent, and treating 401 as permanent each fail a test.
  • Playwright: built the production bundle (npx webpack --mode production) and ran npx playwright test tests-e2e/history-action-confirmation.spec.ts on Chromium locally: 13 passed. The History retry case now stubs a retryable 500, and new cases cover the approval link with 403 and 404 (wording, server message, no try again/retry text, no modal, no POST).

A 403/404 on the approval details fetch means the user lacks view:purchases or account access, so retrying cannot succeed. Say so for those statuses and keep the retry wording for network errors and 5xx. Refs #529.
@cristim cristim added priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint triaged Item has been triaged impact/few Limited audience effort/m Days type/bug Defect labels Oct 5, 2026
@cristim

cristim commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. Your current included review allowance is based on your included PR review attempts over the past 7 days. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 12 minutes.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 4 billable files and costs up to $1.00.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 15 seconds for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 54 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: d1ad0242-02ed-4323-8d58-5c25be006db6
📥 Commits

Reviewing files that changed from the base of the PR and between 5659f3b and 5e57929.

📒 Files selected for processing (4)
  • frontend/src/__tests__/purchases-deeplink.test.ts
  • frontend/src/approval-details.ts
  • frontend/src/purchases-deeplink.ts
  • frontend/tests-e2e/history-action-confirmation.spec.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Keep the server message for 403 and 404, say 404 may mean not found or out of account access, leave History wording as on main, and make the e2e retry case use a retryable 500.
@cristim
cristim merged commit eb7d61b into main Oct 5, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/few Limited audience priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant