fix(commerce-server): return 400/404 from order-status instead of 500 - #1488
Draft
anam-godaddy wants to merge 1 commit into
Draft
anam-godaddy wants to merge 1 commit into
anam-godaddy wants to merge 1 commit into
Conversation
Invalid order IDs (blank, padded, `.`, `..`) and missing orders previously surfaced as 500s, indistinguishable from credential or upstream failures. - getOrderStatus throws InvalidOrderIdError for invalid IDs and OrderNotFoundError when the Orders API returns 404 or the order is bound to another order ID, store, or channel. Incomplete responses stay generic. - The order-status route maps these to 400 and 404; everything else is 500. - Padded IDs are rejected rather than trimmed so the lookup never targets a different ID than the caller supplied. Co-Authored-By: Claude Opus 5.5 <[email protected]>
🦋 Changeset detectedLatest commit: e7d6e79 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
GET /api/commerce/order-statusreturned 500 for every failure, so a bad order ID or a missing order looked the same as a credential or upstream outage..or..orderIdgetOrderStatus()throwsInvalidOrderIdError/OrderNotFoundError(both exported) so in-process callers can branch without parsing messages. The 404 body stays generic and never includes upstream content.' abc'passed validation, was sent upstream untrimmed, and failed the binding check as a 500.Why
Found while triaging an App Builder bug-scan PR (gdcorp-partners/airo-app-builder#11013) against this package. That PR's GraphQL
statusesfix is already superseded here by the Orders REST lookup (5314b51); its route error mapping was the remaining gap.A REST 404 is safe to map to "not found": unlike the storefront subgraph, the Orders API returns completed orders, so a paid order is a 200, never a 404.
Testing
pnpm --filter @godaddy/gd-commerce-server typecheck,lint,test— 174 passed.,.., repeated param — no upstream call), 404 (upstream 404, store mismatch), and 500 (denied token, upstream 500, incomplete order), asserting upstream bodies are never exposed🤖 Generated with Claude Code