{"record":{"id":"557ecd247e71132b","repo":"trpc/trpc","slug":"unsupported-version-version","errorCode":null,"errorMessage":"Unsupported version: ${version}","messagePattern":"Unsupported version: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/adapters/aws-lambda/getPlanner.ts","lineNumber":228,"sourceCode":"      await pipeline(Readable.fromWeb(response.body as any), responseStream);\n    } else {\n      responseStream.end();\n    }\n  },\n};\n\nexport function getPlanner<TEvent extends LambdaEvent>(event: TEvent) {\n  const version = determinePayloadFormat(event);\n  let processor: Processor<TEvent>;\n  switch (version) {\n    case '1.0':\n      processor = v1Processor as Processor<TEvent>;\n      break;\n    case '2.0':\n      processor = v2Processor as Processor<TEvent>;\n      break;\n    default:\n      throw new Error(`Unsupported version: ${version}`);\n  }\n\n  const urlParts = processor.url(event);\n  const url = `https://${urlParts.hostname}${urlParts.pathname}${urlParts.search}`;\n\n  const init: RequestInit = {\n    headers: processor.getHeaders(event),\n    method: processor.getMethod(event),\n    // @ts-expect-error this is fine\n    duplex: 'half',\n  };\n  if (event.body) {\n    init.body = event.isBase64Encoded\n      ? Buffer.from(event.body, 'base64')\n      : event.body;\n  }\n\n  const request = new Request(url, init);","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/trpc/trpc/blob/acff82332de8b4562d3e6975fa8d94ab1a6de5e0/packages/server/src/adapters/aws-lambda/getPlanner.ts#L210-L246","documentation":"`getPlanner(event)` selects a processor based on the API Gateway payload format version. `determinePayloadFormat` returns `'1.0'` when `event.version` is undefined (REST APIs, implied 1.0) and otherwise returns `event.version` verbatim. The switch handles `'1.0'` and `'2.0'` (HTTP APIs); any other value falls through to `default` and throws.","triggerScenarios":"Passing a non-API-Gateway event (ALB invocation, direct Lambda invoke, Function URL with a future/custom format), or an event whose `version` field is something other than `'1.0'`/`'2.0'` (e.g., a typo'd string or a number like `2`).","commonSituations":"Wiring the Lambda adapter to the wrong trigger, future API Gateway versions, or events transformed by a proxy.","solutions":["Confirm the Lambda is fronted by API Gateway (REST = 1.0, HTTP = 2.0) and the event reaches the adapter unmodified.","If `version` is a non-string, normalize it before calling the adapter (the check is strict string equality).","For ALB or Function URL, use the appropriate adapter rather than the API Gateway one."],"exampleFix":"// before\nconst event = { version: 2, ... }; // number, not '2.0'\nawsLambdaRequestHandler({ event, ... }); // throws Unsupported version: 2\n\n// after\nconst event = { ...orig, version: String(orig.version) === '2' ? '2.0' : '1.0' };","handlingStrategy":"validation","validationCode":"const supported = new Set(['1.0', '2.0']);\nconst version = event.version === undefined ? '1.0' : String(event.version);\nif (!supported.has(version)) {\n  throw new Error('Unsupported API Gateway payload version: ' + version);\n}","typeGuard":"const isSupportedVersion = (v: unknown): v is '1.0' | '2.0' =>\n  v === '1.0' || v === '2.0';","tryCatchPattern":"try {\n  awsLambdaRequestHandler({ event, ... });\n} catch (e) {\n  if (e instanceof Error && /Unsupported version/.test(e.message)) {\n    // normalize event.version and retry, or switch adapter\n  }\n  throw e;\n}","preventionTips":["Confirm the Lambda's trigger is API Gateway before deploying.","Coerce `event.version` to a canonical '1.0'/'2.0' string at the entry point."],"tags":["aws-lambda","api-gateway","runtime","event-format"],"backgroundTag":null,"analyzedSha":"acff82332de8b4562d3e6975fa8d94ab1a6de5e0","analyzedAt":"2026-08-12T22:04:41.179Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}