{"record":{"id":"23eaa8e0adb25863","repo":"musistudio/claude-code-router","slug":"plugin-transform-pluginid-request-transform","errorCode":null,"errorMessage":"[plugin:${transform.pluginId}] Request transform ${transform.id} failed: ${formatError(error)}","messagePattern":"\\[plugin:(.+?)\\] Request transform (.+?) failed: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/src/plugins/service.ts","lineNumber":348,"sourceCode":"    for (const transform of this.gatewayRequestTransforms) {\n      const beforeBody = body;\n      const beforeHeaders = headers;\n      const beforeRoutedModel = routedModel;\n      let result: GatewayPluginRequestTransformResult | null | undefined | false;\n      try {\n        result = await transform.transform({\n          body: cloneJsonObject(body),\n          headers: { ...headers },\n          method: input.method,\n          path: input.path,\n          requestId: input.requestId,\n          ...(routedModel ? { routedModel } : {}),\n          ...(input.sessionId ? { sessionId: input.sessionId } : {}),\n          ...(input.tokenCount !== undefined ? { tokenCount: input.tokenCount } : {}),\n          url: input.url\n        }, this.createRequestTransformContext(transform.pluginId));\n      } catch (error) {\n        console.warn(`[plugin:${transform.pluginId}] Request transform ${transform.id} failed: ${formatError(error)}`);\n        continue;\n      }\n      if (!result || !isRecord(result)) {\n        continue;\n      }\n\n      const changes: RequestRouteTraceChange[] = [];\n      const nextBody = isRecord(result.body) ? cloneJsonObject(result.body) : body;\n      if (nextBody && nextBody !== beforeBody && JSON.stringify(nextBody) !== JSON.stringify(beforeBody)) {\n        body = nextBody;\n        changes.push({ operation: beforeBody ? \"replace\" : \"add\", path: \"/body\", scope: \"body\" });\n      }\n\n      const nextHeaders = applyHeaderPatch(headers, result.headers);\n      headers = nextHeaders.headers;\n      changes.push(...nextHeaders.changes(beforeHeaders));\n\n      if (typeof result.routedModel === \"string\" && result.routedModel.trim() && result.routedModel !== beforeRoutedModel) {","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/plugins/service.ts#L330-L366","documentation":"Logged by applyGatewayRequestTransforms when a single registered request transform (plugin transform) throws while processing a request. The transform's result is discarded (continue) and the remaining transforms still run; the request proceeds without that transform's modifications (e.g. no rerouting/rewriting).","triggerScenarios":"A gateway request passes through a plugin transform whose callback throws — bad input shape assumption (missing body/model), a bug in URL manipulation, or context method misuse. Called via pluginTransform during request handling.","commonSituations":"Transform assumes JSON body but receives streaming/empty body; transform written against an older input contract after core upgrade; null sessionId/tokenCount edge cases (the code spreads those conditionally).","solutions":["Pin down which transform from the log (pluginId + transform id) and reproduce with the exact request shape.","Make the transform defensive: check input.body/model before acting and never throw.","Update the plugin to the version matching your core's transform input contract.","If the transform is optional, disable it until fixed — requests pass through unaffected."],"exampleFix":"// before\nconst model = input.body.model as string; // throws if absent\n// after\nconst model = (input.body as Record<string, unknown>)?.model;\nif (typeof model !== 'string') return undefined;","handlingStrategy":"try-catch","validationCode":"const body = input.body as Record<string, unknown> | undefined;\nif (!body || typeof body.model !== 'string') {\n  // skip relying on this transform\n}","typeGuard":"const isTransformSafeInput = (i: unknown): i is { body: Record<string, unknown>; url: string } =>\n  typeof i === 'object' && i !== null && typeof (i as any).url === 'string' &&\n  (i as any).body !== undefined;","tryCatchPattern":"null","preventionTips":["Guard on body/model presence before mutating requests","Keep transforms side-effect free and version-pinned to core","Fail open: return undefined instead of throwing"],"tags":["plugins","request-transform","gateway","degradation"],"backgroundTag":"plugin-transform-failed","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}