Skip to content

CIT-5223: map checkout-in-progress codes in parseShopError - #905

Merged
JoeTravisKiva merged 1 commit into
mainfrom
CIT-5223
Sep 16, 2026
Merged

JoeTravisKiva merged 1 commit into
mainfrom
CIT-5223

Conversation

@JoeTravisKiva

@JoeTravisKiva JoeTravisKiva commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

CIT-5223 — follow-up to CIT-5181 (kiva/ui#7266), which fixed this in kiva/ui but could not reach the paths that route through this package.

Why

The backend now refuses basket edits while the lender's own checkout is still running, returning checkout_in_progress (loan reservation path) or shop.checkoutInProgress (donation, Kiva Card and credit paths).

Neither was mapped in parseShopError, so both fell through to the catch-all:

return new ShopError({ code: 'shop.unknown', original: error }, 'An unknown error occurred.');

Two consequences. The lender sees "An unknown error occurred." — exactly the generic copy CIT-5181 exists to eliminate. And the original code is discarded, rewritten to shop.unknown, so no consumer downstream can classify it. That second part is why this had to be fixed here rather than in kiva/ui.

Reachable today: ExpressCheckoutTotals.vue in kiva/ui calls applyKivaCredit/removeKivaCredit → callShopMutation → parseShopError, then renders e?.message.

What

Maps both codes to lender-facing copy, in the same shape as the existing shop.invalidBasketId / shop.basketRequired / shop.alreadyCheckedOut branch directly above it.

Also adds a test pinning both codes out of hasBasketExpired. They were already absent, so this is a regression guard rather than a behavior change — but that list drives createBasket-and-retry inside callShopMutation/callShopQuery, and retrying against a busy basket would be wrong. The omission should be deliberate, not incidental.

Notes for review

  • The copy is a placeholder, matching the string used in feat: [CIT-5181] show real copy when the basket is locked by an in-flight checkout ui#7266. Both are pending the same design/content review. The lock self-heals after 300s (MysqlBasketRepo::CHECKOUT_LOCK_TTL_SECONDS), so the wording deliberately avoids implying a permanent state.
  • Open question for backend: CIT-5181 names the "credit paths" as a source of shop.checkoutInProgress but doesn't name mutations. Worth confirming addCreditByType/removeCreditByType actually take the checkout lock. The change is harmless if they don't.
  • Consumers need a version bump to pick this up: kiva/ui and cms-page-server. Noted on the ticket.

Testing

@kiva/kv-shop: 14 suites / 91 tests passing, lint clean.

Heads-up for anyone reproducing: on a fresh npm ci the sibling packages aren't built, which makes oneTimeCheckout.spec.ts fail to resolve @kiva/kv-analytics and produces 7 import/* lint errors from @kiva/kv-components. Both are environment, not code — building those two packages first clears them, and the pre-commit hook needs that too.

🤖 Generated with Claude Code

The backend refuses basket edits while the lender's own checkout is
running, returning checkout_in_progress or shop.checkoutInProgress.
Neither was mapped, so parseShopError fell through to its catch-all and
returned "An unknown error occurred." with the code rewritten to
shop.unknown -- discarding the original, so consumers had nothing left
to classify on.

Maps both to lender-facing copy, matching the existing basket-error
handling in this function.

Adds a test pinning both codes OUT of hasBasketExpired. They were
already absent, but that list drives createBasket-and-retry in
callShopMutation/callShopQuery, and retrying a busy basket would be
wrong. The test makes the omission deliberate rather than incidental.

CIT-5223

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@JoeTravisKiva
JoeTravisKiva marked this pull request as ready for review September 16, 2026 21:11
@mcstover
mcstover requested a review from a team September 16, 2026 21:14
@JoeTravisKiva
JoeTravisKiva merged commit b09937e into main Sep 16, 2026
5 checks passed
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.

3 participants