gchq/CyberChef · error · OperationError
${err}
Error message
${err} What it means
Catch-all OperationError thrown by 'VarInt Decode' when the decode loop throws for any reason. The operation expects a byteArray input; the BigInt path reads input[i] & 0x7f per byte. Any non-numeric/NaN byte (e.g. the byteArray contains non-integer or out-of-range entries) makes the BigInt bitwise op throw, which is rewrapped here.
Source
Thrown at src/core/operations/VarIntDecode.mjs:51
* @param {Object[]} args
* @returns {number}
*/
run(input, args) {
try {
if (typeof BigInt === "function") {
let result = BigInt(0);
let offset = BigInt(0);
for (let i = 0; i < input.length; i++) {
result |= BigInt(input[i] & 0x7f) << offset;
if (!(input[i] & 0x80)) break;
offset += BigInt(7);
}
return result.toString();
} else {
return Protobuf.varIntDecode(input).toString();
}
} catch (err) {
throw new OperationError(err);
}
}
}
export default VarIntDecode;
View on GitHub (pinned to 4290ea7539)
Solutions
- Ensure the input is a valid byteArray (run 'From Hex' or 'To ByteArray' first).
- Confirm each byte is an integer in 0-255.
- Inspect the wrapped err message in the OperationError for the underlying cause.
Example fix
// before: feeding a hex string directly // after: convert to bytes first recipe: [ "From Hex", "VarInt Decode" ]
Defensive patterns
Strategy: validation
Validate before calling
if (!Array.isArray(input) || input.some(b => typeof b !== "number" || b < 0 || b > 255 || !Number.isInteger(b))) {
throw new Error("VarInt Decode expects a byteArray of integers 0-255");
} Type guard
function isByteArray(data) { return Array.isArray(data) && data.every(b => Number.isInteger(b) && b >= 0 && b <= 255); } Try / catch
try { return varIntDecode(input); }
catch (err) { throw new Error(`VarInt decode failed: ${err.message}`); } Prevention
- Insert a 'From Hex' / 'To ByteArray' step before VarInt Decode.
- Ensure upstream operations output byteArray type.
When it happens
Trigger: Feeding input that is not a clean byteArray of integers 0-255, feeding an empty input that downstream code mishandles, or running the operation with an inputType that produced non-byte values. The catch also wraps any error from the Protobuf fallback path when BigInt is unavailable.
Common situations: Chaining from an operation that emits a string or non-byteArray type into VarInt Decode without a To ByteArray / From Hex step, or malformed varint streams.
Related errors
- ${err}
- Negative values cannot be represented as VarInt
- Schema Error: Schema not defined
- Input Error: ${error}
- Schema ${error}
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/1016e842d17a1906.
Report an issue: GitHub.