{"record":{"id":"283dd00701246a32","repo":"earendil-works/pi","slug":"decoded-cbor-integer-is-outside-the-safe-range","errorCode":null,"errorMessage":"Decoded CBOR integer is outside the safe range","messagePattern":"Decoded CBOR integer is outside the safe range","errorType":"exception","errorClass":"CborError","httpStatus":null,"severity":"error","filePath":"packages/protocol/src/cbor/decoder.ts","lineNumber":39,"sourceCode":"\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;\n\t\t\t}\n\t\t\tcase 2: {\n\t\t\t\tconst length = this.readLength(additionalInformation, \"byte string\", this.options.maxByteLength);\n\t\t\t\treturn new Uint8Array(this.readBytes(length));\n\t\t\t}\n\t\t\tcase 3: {\n\t\t\t\tconst length = this.readLength(additionalInformation, \"text string\", this.options.maxByteLength);\n\t\t\t\tconst bytes = this.readBytes(length);\n\t\t\t\ttry {\n\t\t\t\t\treturn textDecoder.decode(bytes);\n\t\t\t\t} catch (_error) {\n\t\t\t\t\tthrow new CborError(\"CBOR text string contains invalid UTF-8\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 4: {\n\t\t\t\tconst length = this.readLength(additionalInformation, \"array\", this.options.maxContainerLength);\n\t\t\t\tconst result: unknown[] = [];","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/protocol/src/cbor/decoder.ts#L21-L57","documentation":"Error \"Decoded CBOR integer is outside the safe range\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/protocol/src/cbor/decoder.ts:39 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"}