{"record":{"id":"6aa8914993189d95","repo":"musistudio/claude-code-router","slug":"openrouter-discount-routing-skipped-formaterror","errorCode":null,"errorMessage":"OpenRouter discount routing skipped: ${formatError(error)}","messagePattern":"OpenRouter discount routing skipped: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/src/plugins/built-ins/openrouter-discount-provider-router.ts","lineNumber":102,"sourceCode":"const pendingSelections = new Map<string, PendingSelection>();\n\nexport const openRouterDiscountProviderRouterTransform: GatewayPluginRequestTransformHandler = async (\n  input,\n  context\n) => {\n  const body = cloneRecord(input.body);\n  if (!body) {\n    return undefined;\n  }\n  const target = resolveOpenRouterDiscountRoutingTarget(input, context.config);\n  if (!target) {\n    return undefined;\n  }\n\n  try {\n    return await routeOpenRouterRequestByEndpointDiscount(input, body, target);\n  } catch (error) {\n    context.logger.warn(`OpenRouter discount routing skipped: ${formatError(error)}`);\n    return undefined;\n  }\n};\n\nasync function routeOpenRouterRequestByEndpointDiscount(\n  input: GatewayPluginRequestTransformInput,\n  body: Record<string, unknown>,\n  target: OpenRouterDiscountRoutingTarget\n): Promise<GatewayPluginRequestTransformResult | undefined> {\n  const existingProvider = isRecord(body.provider) ? body.provider : {};\n  const existingOrder = readStringArray(existingProvider.order);\n  const providerIgnore = mergeStringLists(readStringArray(existingProvider.ignore), target.settings.providerBlacklist);\n  if (target.settings.respectExistingProviderOrder && existingOrder.length > 0) {\n    return undefined;\n  }\n\n  const endpoints = await loadModelEndpoints(target.provider, target.model, target.settings);\n  const promptTokens = Math.max(positiveNumber(input.tokenCount) ?? 0, estimatePromptTokens(body));","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/plugins/built-ins/openrouter-discount-provider-router.ts#L84-L120","documentation":"Logged by the OpenRouter discount provider router plugin transform when routeOpenRouterRequestByEndpointDiscount throws while inspecting/rerouting a request. The transform deliberately degrades gracefully: it warns and returns undefined so the request proceeds unchanged through the gateway without discount routing.","triggerScenarios":"An OpenRouter-bound request whose body cannot be parsed as expected (non-JSON body, unexpected model string), missing/invalid OpenRouter pricing metadata configured for the plugin, or a bug in the discount lookup for the specific endpoint being called.","commonSituations":"Client sends a streaming or non-JSON payload the router tries to read; OpenRouter changes endpoint path shapes; the plugin's discount config references endpoints that no longer exist.","solutions":["Inspect the formatted error; if it is a body-parse failure, restrict the router plugin to JSON chat-completion endpoints or disable it for other routes.","Update the plugin's endpoint discount configuration to match current OpenRouter catalog paths.","Upgrade the core package for fixes to the router's parsing logic.","As a stopgap, disable the openrouter-discount-provider-router plugin — requests route normally at list price."],"exampleFix":"// plugin config: disable discount routing if it keeps failing\n// before\n{\"plugins\":[\"openrouter-discount-provider-router\"]}\n// after\n{\"plugins\":[]}","handlingStrategy":"fallback","validationCode":"null","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Keep OpenRouter endpoint discount config in sync with the current catalog","Send well-formed JSON bodies to OpenRouter routes","Disable the router plugin when it repeatedly skips"],"tags":["openrouter","plugin","request-routing","degradation"],"backgroundTag":"plugin-transform-failed","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}