Skip to content

fix(checkout): index categories from the catalog items lookup - #58

Merged
mekedron merged 1 commit into
mekedron:mainfrom
vsem-azamat:fix/checkout-items-lookup-categories
Oct 17, 2026
Merged

mekedron merged 1 commit into
mekedron:mainfrom
vsem-azamat:fix/checkout-items-lookup-categories

Conversation

@vsem-azamat

Copy link
Copy Markdown
Contributor

Problem

wolt checkout (and wolt_checkout_preview over MCP) fails for a Tesco Hypermarket basket in Prague:

WOLT_CHECKOUT_PAYLOAD_ERROR: unable to resolve category_id for basket item "1dfd4b067979bfe1b97d9236"

For this venue:

  • the item page (order-xp/web/v1/pages/venue/<id>/item/<item>) returns {"id": …, "venue_id": …, "sections": []}, with no category;
  • the items lookup (POST …/assortment/items with item_ids) returns the mapping only as categories: [{"id": "0ff8ad8c…", "item_ids": ["1dfd4b06…"]}], and the item records have no category field;
  • the search fallback queries the basket line name. That name is localized (English, Franz Josef Kaiser Exclusive Green Olives Stuffed with Blue Cheese Paste 300g) while the venue catalog is Czech, so the search finds nothing.

Build searched the items-lookup payload item by item through resolveCheckoutCategoryIDFromCatalogPayload, which only reads fields on the item. Its categories[].item_ids mapping was never indexed. Items whose name search happened to match still worked; in the same basket the cucumber resolved and the olives did not.

Fix

Run buildCheckoutCategoryIDIndex over the items-lookup payloads too: the caller-supplied current catalog and any fetched lookup. This is the same treatment the item page, search and venue content payloads already get. The category then resolves from the lookup that is already made, without the extra search.

Tests

  • New TestBuildResolvesCategoryFromCatalogItemsCategoryList uses the real payload shapes: an empty item page, a lookup with categories[].item_ids only, and a search that finds nothing. It fails on main with the same unable to resolve category_id error and passes with the fix. It also asserts that no search request is needed.
  • go build ./..., version check, golangci-lint run (v2.4.0 config, 0 issues), go test ./... and go test -race ./... all pass.
  • Live: with the patch, wolt checkout --venue-id 6539247b9eecd6092fb9e117 returns a preview for the 17-line basket that failed before.

The items lookup that Build runs for the basket's ids maps each item to its
category through categories[].item_ids; the item records themselves carry no
category field. That payload was only searched item by item, so the mapping
was never used. When the item page came back empty and the search by the
basket's line name (localized, e.g. English for a Czech venue) found nothing,
checkout preview failed with "unable to resolve category_id".

Index the lookup payloads like the item page, search and venue content
payloads, so the category resolves without the extra search.

@mekedron mekedron left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! Reviewed and verified locally:

  • The new test fails on main with the same unable to resolve category_id error and passes with the fix.
  • Precedence is unchanged where it matters: category fields on the basket line and the item page still win, and the assortment index is merged first, so the lookup mapping only fills gaps.
  • Full pre-push gate (build, version check, golangci-lint, go test, go test -race) and the read-only live smoke pass.

@mekedron
mekedron merged commit 6b3141f into mekedron:main Oct 17, 2026
3 checks passed
@mekedron

Copy link
Copy Markdown
Owner

Thanks a lot for the fix and for such a clear write-up, @vsem-azamat! The real payload shapes in the test and the live check made this an easy review. It's merged and shipped in v2.5.1.

Also thanks for digging into the multi-count pricing in #59. I'll take that one in a separate PR, so no need to open one for it.

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.

2 participants