{"record":{"id":"3bff1d34639ec38b","repo":"koala73/worldmonitor","slug":"unsupported-commodity-symbol-symbols-length-1","errorCode":null,"errorMessage":"Unsupported commodity symbol${symbols.length === 1 ? '' : 's'}: ${symbols.join(', ')}","messagePattern":"Unsupported commodity symbol(.+?): (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"server/worldmonitor/market/v1/list-commodity-quotes.ts","lineNumber":47,"sourceCode":"  commodityConfig.commodities.map((c) => c.symbol),\n);\n\nexport function normalizeCommoditySymbol(raw: string): string {\n  return raw.trim().replace(/\\s+/g, '').slice(0, 32).toUpperCase();\n}\n\n/**\n * Throw the generated ValidationError for unsupported requested symbols.\n *\n * ValidationError is the documented 400 shape: the sebuf generated dispatch\n * (service_server.ts) catches instanceof ValidationError and serializes it as\n * `{ violations: [...] }` — matching the published OpenAPI 400 `ValidationError`\n * schema. A bare `{ message }` 400 (e.g. an error carrying statusCode=400 via\n * the error mapper) is NOT in that operation's 400 oneOf, so using it here\n * would document a response shape the handler never actually returns.\n */\nexport function throwUnsupportedCommodityError(symbols: string[]): never {\n  throw new ValidationError([\n    {\n      field: 'symbols',\n      description: `Unsupported commodity symbol${symbols.length === 1 ? '' : 's'}: ${symbols.join(', ')}`,\n    },\n  ]);\n}\n\n/**\n * Resolve requested symbols against the supported commodity set.\n * - Empty request → `{ symbols: [] }` (caller returns the full default set).\n * - Caps cardinality (over-cap is truncated) and deduplicates in request order.\n * - Throws ValidationError (→ HTTP 400 `{ violations }`) on any requested\n *   symbol that is not in the supported set — unsupported symbols are\n *   explicit, never silent.\n */\nexport function resolveCommodityQuery(\n  rawSymbols: string[],\n  supported: ReadonlySet<string> = SUPPORTED_COMMODITY_SYMBOLS,","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/server/worldmonitor/market/v1/list-commodity-quotes.ts#L29-L65","documentation":"Validation in throwUnsupportedCommodityError (list-commodity-quotes): after normalizeCommoditySymbol processing, some requested symbols (listed in the message) are not in the configured commodity symbol set. Thrown as the generated ValidationError so the sebuf dispatch serializes the documented 400 violations shape rather than a bare message 400.","triggerScenarios":"Thrown at server/worldmonitor/market/v1/list-commodity-quotes.ts:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Request only symbols present in the commodity config (commodityConfig.commodities)","Validate the symbol list client-side against the supported set before calling","If a symbol should be supported, add it to the commodity config and regenerate"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"eeab0a219fce0f02a00603b532dbae9041b934ac","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}