Skip to content

fix(account): view-as Orders page crash — admin orders missing currency/email fields#268

Merged
kilbot merged 1 commit into
mainfrom
fix/impersonation-order-fields
Jul 6, 2026
Merged

fix(account): view-as Orders page crash — admin orders missing currency/email fields#268
kilbot merged 1 commit into
mainfrom
fix/impersonation-order-fields

Conversation

@kilbot

@kilbot kilbot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

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/orders omits email, currency_code, subtotal, and tax_total. The account order projection formats money with order.currency_code; when it was undefined, currency formatting threw and the error boundary caught it.

Fix

Request an explicit fields set (incl. *items + metadata) on both admin order fetchers (listAdminCustomerOrders, getAdminCustomerOrderById). Verified against prod: with the field list, /admin/orders returns currency_code, email, and full line items with metadata. Unit tests assert both fetchers request the fields.

Validation

  • medusa-admin tests (12) + order/projection consumers (25) green; lint clean.
  • ⏳ Full end-to-end confirmation is post-deploy: inspect a customer → Orders page loads.

⚠️ Separately discovered (NOT this PR): activations always show 0

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_TOKEN is not set in Vercel prod, so the authed Keygen calls (GET /v1/licenses/{id} + /machines) return 401; resolveLicenseReference falls back to the public validate-key path, which hardcodes machines: []. Machine deactivation from the account page would also fail (same auth). Fix is infra (provision KEYGEN_API_TOKEN), not code — tracked separately.

… 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.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kilbot has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 3 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d1203d89-59f9-4e90-b6b5-bddd345ce608

📥 Commits

Reviewing files that changed from the base of the PR and between 1aa4f93 and 643edaa.

📒 Files selected for processing (2)
  • src/lib/discord/medusa-admin.test.ts
  • src/lib/discord/medusa-admin.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/impersonation-order-fields

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

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

🚀 Preview: https://wcpos-noejmstdf-wcpos.vercel.app

@kilbot kilbot merged commit 448b797 into main Jul 6, 2026
9 checks passed
@kilbot kilbot deleted the fix/impersonation-order-fields branch July 6, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant