{"record":{"id":"0fb78d52bda4af20","repo":"earendil-works/pi","slug":"cbor-integers-must-be-safe-javascript-integers","errorCode":null,"errorMessage":"CBOR integers must be safe JavaScript integers","messagePattern":"CBOR integers must be safe JavaScript integers","errorType":"exception","errorClass":"CborError","httpStatus":null,"severity":"error","filePath":"packages/protocol/src/cbor/encoder.ts","lineNumber":140,"sourceCode":"\toptions: ResolvedCborOptions,\n\tdepth: number,\n\tancestors: Set<object>,\n): void {\n\tif (depth > options.maxDepth)\n\t\tthrow new CborError(`CBOR nesting depth exceeds configured limit of ${options.maxDepth}`);\n\n\tif (value === null) {\n\t\twriter.writeByte(0xf6);\n\t\treturn;\n\t}\n\tif (typeof value === \"boolean\") {\n\t\twriter.writeByte(value ? 0xf5 : 0xf4);\n\t\treturn;\n\t}\n\tif (typeof value === \"number\") {\n\t\tif (!Number.isFinite(value)) throw new CborError(\"CBOR numbers must be finite\");\n\t\tif (Number.isInteger(value) && !Object.is(value, -0)) {\n\t\t\tif (!Number.isSafeInteger(value)) throw new CborError(\"CBOR integers must be safe JavaScript integers\");\n\t\t\tif (value >= 0) writeArgument(writer, 0, value);\n\t\t\telse writeArgument(writer, 1, -1 - value);\n\t\t} else {\n\t\t\twriter.writeFloat64(value);\n\t\t}\n\t\treturn;\n\t}\n\tif (typeof value === \"string\") {\n\t\tencodeText(writer, value, options);\n\t\treturn;\n\t}\n\tif (value instanceof Uint8Array) {\n\t\tif (value.byteLength > options.maxByteLength) {\n\t\t\tthrow new CborError(`CBOR byte string length exceeds configured limit of ${options.maxByteLength}`);\n\t\t}\n\t\twriteArgument(writer, 2, value.byteLength);\n\t\twriter.writeBytes(value);\n\t\treturn;","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/protocol/src/cbor/encoder.ts#L122-L158","documentation":"Error \"CBOR integers must be safe JavaScript integers\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/protocol/src/cbor/encoder.ts:140 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only encode safe integers (Number.isSafeInteger); round the value or use a string for larger integers."],"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"}