{"record":{"id":"1022c7b0d32bf5b5","repo":"decolua/9router","slug":"aws-eventstream-header-name-has-unknown-type","errorCode":null,"errorMessage":"AWS EventStream header ${name} has unknown type ${type}","messagePattern":"AWS EventStream header (.+?) has unknown type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"open-sse/executors/kiro.js","lineNumber":1267,"sourceCode":"      requireBytes(4);\n      headers[name] = view.getInt32(offset, false);\n      offset += 4;\n    } else if (type === 5 || type === 8) {\n      requireBytes(8);\n      offset += 8;\n    } else if (type === 6 || type === 7) {\n      requireBytes(2);\n      const valueLength = view.getUint16(offset, false);\n      offset += 2;\n      requireBytes(valueLength);\n      const bytes = data.subarray(offset, offset + valueLength);\n      headers[name] = type === 7 ? decoder.decode(bytes) : bytes;\n      offset += valueLength;\n    } else if (type === 9) {\n      requireBytes(16);\n      offset += 16;\n    } else {\n      throw new Error(`AWS EventStream header ${name} has unknown type ${type}`);\n    }\n  }\n\n  const payloadBytes = data.subarray(headerEnd, totalLength - 4);\n  if (payloadBytes.byteLength === 0) return { headers, payload: null };\n  const payloadText = decoder.decode(payloadBytes);\n  if (!payloadText.trim()) return { headers, payload: null };\n  try {\n    return { headers, payload: JSON.parse(payloadText) };\n  } catch (error) {\n    throw new Error(`AWS EventStream payload is not valid JSON (${error.message})`);\n  }\n}\n\nexport default KiroExecutor;\n","sourceCodeStart":1249,"sourceCodeEnd":1283,"githubUrl":"https://github.com/decolua/9router/blob/90b52e06ffd666b7929554211474d01588f6b1f8/open-sse/executors/kiro.js#L1249-L1283","documentation":"EventStream header values carry a 1-byte type code (0..13 in the AWS spec: true/false, int8/16/32/64, byte arrays, strings, timestamps, UUIDs). parseEventFrame() only implements the types Kiro actually uses; when it encounters a type code outside the implemented set it throws this error naming the header and the unknown type, since it cannot decode the value safely.","triggerScenarios":"A Kiro frame contains a header whose type byte is not one of the implemented codes (e.g. 5/6/8/10..13 — 64-bit ints, timestamps, UUID variants). This happens when Kiro's backend starts emitting a new header type, or when corrupted data shifts the type-byte position so a random byte is read as the type.","commonSituations":"Kiro ships a protocol update adding new header types before the parser supports them; corrupted stream data from a proxy misaligns the header walk so a value byte is misread as a type code; running a stale 9router version against a newer upstream.","solutions":["Update 9router to the latest version — new header types are added to the parser as Kiro's protocol evolves","Log the frame as hex and note the header name/type shown in the message; if type 5/6/8 etc., it is a genuine protocol addition needing a parser update","Retry the request; if the error appears only sporadically it is likely corruption rather than protocol drift","Bypass proxies that rewrite binary bodies to rule out byte misalignment","Report the header name and type from the message to the 9router maintainers if the latest version still throws"],"exampleFix":"// before (kiro.js parser)\n} else {\n  throw new Error(`AWS EventStream header ${name} has unknown type ${type}`);\n}\n// after (workaround: skip unsupported fixed-size types)\n} else if (type === 5 || type === 6) { requireBytes(8); offset += 8; headers[name] = null;\n} else {\n  throw new Error(`AWS EventStream header ${name} has unknown type ${type}`);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await executor.execute(req);\n} catch (e) {\n  const m = e.message.match(/unknown type (\\d+)/);\n  if (m) {\n    log.warn('unsupported eventstream header type', { type: +m[1] });\n    return retryOrFallback(req);\n  }\n  throw e;\n}","preventionTips":["Update 9router promptly after Kiro protocol changes","Log header name/type from the message and report persistent new types to maintainers","Avoid byte-rewriting proxies that can misalign the header walk"],"tags":["kiro","eventstream","binary-protocol","unsupported-type"],"backgroundTag":"eventstream-frame-malformed","analyzedSha":"90b52e06ffd666b7929554211474d01588f6b1f8","analyzedAt":"2026-08-30T21:05:45.952Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}