earendil-works/pi · error · CborError
CBOR arrays must not contain holes or undefined values
Error message
CBOR arrays must not contain holes or undefined values
What it means
During array encoding, an index is a hole (missing own property) or explicitly undefined. Holes and undefined have no CBOR representation in the protocol subset (map keys/optional slots excepted), so sparse arrays must be compacted or filled with null before encoding.
Solutions
- Replace undefined values and array holes with null before encoding.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/protocol/src/cbor/encoder.ts:170 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/6daae6a6c5c12754.
Report an issue: GitHub.
Appendix: source
Thrown at packages/protocol/src/cbor/encoder.ts:170
if (value instanceof Uint8Array) {
if (value.byteLength > options.maxByteLength) {
throw new CborError(`CBOR byte string length exceeds configured limit of ${options.maxByteLength}`);
}
writeArgument(writer, 2, value.byteLength);
writer.writeBytes(value);
return;
}
if (Array.isArray(value)) {
if (ancestors.has(value)) throw new CborError("CBOR values must not contain cycles");
if (value.length > options.maxContainerLength) {
throw new CborError(`CBOR array length exceeds configured limit of ${options.maxContainerLength}`);
}
ancestors.add(value);
try {
writeArgument(writer, 4, value.length);
for (let index = 0; index < value.length; index++) {
if (!Object.hasOwn(value, index) || value[index] === undefined) {
throw new CborError("CBOR arrays must not contain holes or undefined values");
}
encodeValue(writer, value[index], options, depth + 1, ancestors);
}
} finally {
ancestors.delete(value);
}
return;
}
if (isPlainObject(value)) {
if (ancestors.has(value)) throw new CborError("CBOR values must not contain cycles");
for (const symbol of Object.getOwnPropertySymbols(value)) {
if (Object.prototype.propertyIsEnumerable.call(value, symbol)) {
throw new CborError("CBOR map keys must be strings");
}
}
const entries: Array<readonly [string, unknown]> = [];
for (const key of Object.keys(value)) {
const entryValue = value[key];View on GitHub (pinned to 4af9d21d3b)