earendil-works/pi · error · CborError
CBOR map contains a duplicate key
Error message
CBOR map contains a duplicate key
What it means
Fires in the CBOR decoder's map branch when the same string key appears twice within a single map. The strict decoder rejects duplicates because a plain Record cannot represent them and the second value would silently overwrite the first, so a duplicate signals a payload not conforming to the protocol's strict RFC 8949 subset (likely a corrupt, malicious, or non-conforming encoder).
Solutions
- Fix the encoder producing the CBOR map so each key appears once; the decoder rejects maps with duplicate keys.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/protocol/src/cbor/decoder.ts:68 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/0404e62efc7b68f4.
Report an issue: GitHub.
Appendix: source
Thrown at packages/protocol/src/cbor/decoder.ts:68
return textDecoder.decode(bytes);
} catch (_error) {
throw new CborError("CBOR text string contains invalid UTF-8");
}
}
case 4: {
const length = this.readLength(additionalInformation, "array", this.options.maxContainerLength);
const result: unknown[] = [];
for (let index = 0; index < length; index++) result.push(this.readItem(depth + 1));
return result;
}
case 5: {
const length = this.readLength(additionalInformation, "map", this.options.maxContainerLength);
const result: Record<string, unknown> = {};
const keys = new Set<string>();
for (let index = 0; index < length; index++) {
const key = this.readItem(depth + 1);
if (typeof key !== "string") throw new CborError("CBOR map keys must be strings");
if (keys.has(key)) throw new CborError("CBOR map contains a duplicate key");
keys.add(key);
Object.defineProperty(result, key, {
configurable: true,
enumerable: true,
value: this.readItem(depth + 1),
writable: true,
});
}
return result;
}
case 6:
throw new CborError("CBOR tags are not supported");
case 7:
return this.readSimple(additionalInformation);
default:
throw new CborError("Malformed CBOR major type");
}
}View on GitHub (pinned to 4af9d21d3b)