fix(account): view-as Orders page crash — admin orders missing currency/email fields#268
Conversation
… orders /admin/orders omits email, currency_code, subtotal, tax_total by default, unlike /store/orders. The undefined currency_code threw when the account Orders page formatted money, so 'view as' crashed with 'Something went wrong'. Request the full field set (incl. *items + metadata) on both admin order fetchers.
There was a problem hiding this comment.
kilbot has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 3 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
🚀 Preview: https://wcpos-noejmstdf-wcpos.vercel.app |
Fix: "view as" Orders page crash (missing admin-order fields)
Follow-up to #262. When inspecting a customer, the Orders page threw "Something went wrong loading this page."
Root cause
Under "view as", orders are fetched via
/admin/orders(admin token) instead of/store/orders. The two endpoints return different default field sets —/admin/ordersomitsemail,currency_code,subtotal, andtax_total. The account order projection formats money withorder.currency_code; when it wasundefined, currency formatting threw and the error boundary caught it.Fix
Request an explicit
fieldsset (incl.*items+metadata) on both admin order fetchers (listAdminCustomerOrders,getAdminCustomerOrderById). Verified against prod: with the field list,/admin/ordersreturnscurrency_code,email, and full line items with metadata. Unit tests assert both fetchers request the fields.Validation
medusa-admintests (12) + order/projection consumers (25) green; lint clean.While debugging, I found the Licenses page shows "0 of N activations" for every customer — a pre-existing prod bug unrelated to "view as."
KEYGEN_API_TOKENis not set in Vercel prod, so the authed Keygen calls (GET /v1/licenses/{id}+/machines) return 401;resolveLicenseReferencefalls back to the publicvalidate-keypath, which hardcodesmachines: []. Machine deactivation from the account page would also fail (same auth). Fix is infra (provisionKEYGEN_API_TOKEN), not code — tracked separately.