koala73/worldmonitor · error · ValidationError

Unsupported commodity symbol${symbols.length === 1 ? '' : 's

Error message

Unsupported commodity symbol${symbols.length === 1 ? '' : 's'}: ${symbols.join(', ')}

What it means

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.

Source

Thrown at server/worldmonitor/market/v1/list-commodity-quotes.ts:47

  commodityConfig.commodities.map((c) => c.symbol),
);

export function normalizeCommoditySymbol(raw: string): string {
  return raw.trim().replace(/\s+/g, '').slice(0, 32).toUpperCase();
}

/**
 * Throw the generated ValidationError for unsupported requested symbols.
 *
 * ValidationError is the documented 400 shape: the sebuf generated dispatch
 * (service_server.ts) catches instanceof ValidationError and serializes it as
 * `{ violations: [...] }` — matching the published OpenAPI 400 `ValidationError`
 * schema. A bare `{ message }` 400 (e.g. an error carrying statusCode=400 via
 * the error mapper) is NOT in that operation's 400 oneOf, so using it here
 * would document a response shape the handler never actually returns.
 */
export function throwUnsupportedCommodityError(symbols: string[]): never {
  throw new ValidationError([
    {
      field: 'symbols',
      description: `Unsupported commodity symbol${symbols.length === 1 ? '' : 's'}: ${symbols.join(', ')}`,
    },
  ]);
}

/**
 * Resolve requested symbols against the supported commodity set.
 * - Empty request → `{ symbols: [] }` (caller returns the full default set).
 * - Caps cardinality (over-cap is truncated) and deduplicates in request order.
 * - Throws ValidationError (→ HTTP 400 `{ violations }`) on any requested
 *   symbol that is not in the supported set — unsupported symbols are
 *   explicit, never silent.
 */
export function resolveCommodityQuery(
  rawSymbols: string[],
  supported: ReadonlySet<string> = SUPPORTED_COMMODITY_SYMBOLS,

View on GitHub (pinned to eeab0a219f)

Solutions

  1. Request only symbols present in the commodity config (commodityConfig.commodities)
  2. Validate the symbol list client-side against the supported set before calling
  3. If a symbol should be supported, add it to the commodity config and regenerate
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/worldmonitor/market/v1/list-commodity-quotes.ts:47 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of koala73/worldmonitor@eeab0a219f (2026-08-21). Data as JSON: /api/errors/3bff1d34639ec38b. Report an issue: GitHub.