{"record":{"id":"ad0f9a7bb0cb41d3","repo":"earendil-works/pi","slug":"cbor-payload-contains-trailing-data","errorCode":null,"errorMessage":"CBOR payload contains trailing data","messagePattern":"CBOR payload contains trailing data","errorType":"exception","errorClass":"CborError","httpStatus":null,"severity":"error","filePath":"packages/protocol/src/cbor/decoder.ts","lineNumber":22,"sourceCode":"\ttype ResolvedCborOptions,\n\tresolveOptions,\n\ttextDecoder,\n\tUINT32_BASE,\n} from \"./options.ts\";\n\nclass CborReader {\n\tprivate readonly bytes: Uint8Array;\n\tprivate offset = 0;\n\tprivate readonly options: ResolvedCborOptions;\n\n\tconstructor(bytes: Uint8Array, options: ResolvedCborOptions) {\n\t\tthis.bytes = bytes;\n\t\tthis.options = options;\n\t}\n\n\tdecode(): unknown {\n\t\tconst value = this.readItem(0);\n\t\tif (this.offset !== this.bytes.byteLength) throw new CborError(\"CBOR payload contains trailing data\");\n\t\treturn value;\n\t}\n\n\tprivate readItem(depth: number): unknown {\n\t\tif (depth > this.options.maxDepth) {\n\t\t\tthrow new CborError(`CBOR nesting depth exceeds configured limit of ${this.options.maxDepth}`);\n\t\t}\n\t\tconst initial = this.readByte();\n\t\tconst majorType = initial >>> 5;\n\t\tconst additionalInformation = initial & 0x1f;\n\n\t\tswitch (majorType) {\n\t\t\tcase 0:\n\t\t\t\treturn this.readArgument(additionalInformation);\n\t\t\tcase 1: {\n\t\t\t\tconst value = -1 - this.readArgument(additionalInformation);\n\t\t\t\tif (!Number.isSafeInteger(value)) throw new CborError(\"Decoded CBOR integer is outside the safe range\");\n\t\t\t\treturn value;","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/protocol/src/cbor/decoder.ts#L4-L40","documentation":"Error \"CBOR payload contains trailing data\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/protocol/src/cbor/decoder.ts:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}