{"record":{"id":"4a095d45950be6e3","repo":"koala73/worldmonitor","slug":"expected-the-essentials-basket-for-the-selected-market","errorCode":null,"errorMessage":"Expected the essentials basket for the selected market","messagePattern":"Expected the essentials basket for the selected market","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"server/worldmonitor/consumer-prices/v1/_selection.ts","lineNumber":14,"sourceCode":"import { ValidationError } from '../../../../src/generated/server/worldmonitor/consumer_prices/v1/service_server';\n\nconst MARKETS = new Set(['ae', 'sa', 'ch', 'sg', 'us', 'gb', 'br', 'in', 'au', 'ke']);\n\nexport function resolveConsumerPriceSelection(marketCode = '', basketSlug = ''): { market: string; basket: string } {\n  if (marketCode.length > 2) {\n    throw new ValidationError([{ field: 'marketCode', description: 'Expected a supported two-letter market code' }]);\n  }\n  const market = marketCode.toLowerCase() || 'ae';\n  if (!MARKETS.has(market)) {\n    throw new ValidationError([{ field: 'marketCode', description: 'Expected a supported two-letter market code' }]);\n  }\n  if (basketSlug.length > 13) {\n    throw new ValidationError([{ field: 'basketSlug', description: 'Expected the essentials basket for the selected market' }]);\n  }\n  const basket = basketSlug.toLowerCase() || `essentials-${market}`;\n  if (basket !== `essentials-${market}`) {\n    throw new ValidationError([{ field: 'basketSlug', description: 'Expected the essentials basket for the selected market' }]);\n  }\n  return { market, basket };\n}\n","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/koala73/worldmonitor/blob/e586b8b4b80f595aa7ece295eec10d76f2921240/server/worldmonitor/consumer-prices/v1/_selection.ts#L1-L22","documentation":"A basket slug longer than 13 characters throws ValidationError('Expected the essentials basket for the selected market'). Only the essentials basket is served: the slug must be exactly `essentials-<market>` (max 2+10=12-13 chars).","triggerScenarios":"Passing basketSlug like 'essentials-us-premium', 'full-basket-us', or any custom slug exceeding 13 characters to a consumer-prices endpoint.","commonSituations":"Clients guessing basket names; copied URLs from other product surfaces with richer baskets; attempting to request non-essentials baskets that this API does not support.","solutions":["Use the exact slug `essentials-<market>` (e.g. essentials-us) or omit basketSlug to get the default","Shorten or remove the custom basket suffix from the request","Do not append qualifiers like '-premium' to the basket slug","If a richer basket is needed, request a new server-side basket instead of a longer slug"],"exampleFix":"// before\ngetConsumerPrices({ market: 'us', basket: 'essentials-us-extended' });\n// after\ngetConsumerPrices({ market: 'us', basket: 'essentials-us' });","handlingStrategy":"validation","validationCode":"if (basket && basket.length > 13) throw new Error('basket slug too long');","typeGuard":"const isShortBasketSlug = (b) => typeof b === 'string' && b.length <= 13;","tryCatchPattern":"try { return await getConsumerPrices(req); } catch (e) { if (e?.fieldViolations?.[0]?.field === 'basketSlug') { return getConsumerPrices({ ...req, basket: undefined }); } throw e; }","preventionTips":["Always derive basket as `essentials-${market}`","Never append suffixes to the basket slug","Omit basket entirely and rely on the server default","Validate slug length in the client request builder"],"tags":["validation","consumer-prices","api"],"backgroundTag":"invalid-argument-value","analyzedSha":"e586b8b4b80f595aa7ece295eec10d76f2921240","analyzedAt":"2026-09-22T01:50:49.965Z","contentChangedAt":"2026-09-22T01:50:49.965Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}