gchq/CyberChef · error · OperationError
Encountered a non-implemented type: ${typeof content}
Error message
Encountered a non-implemented type: ${typeof content} What it means
The serializeBasicTypes() function handles boolean, number, and string. If none match (the value is a BigInt, Symbol, undefined, or function disguised as a primitive), this 'should be unreachable' throw fires. It is a defensive guard for types the serializer was never designed to handle at the leaf level.
Source
Thrown at src/core/operations/PHPSerialize.mjs:77
* cast to 0 or 1
*/
if (typeof content === "boolean") {
return `${basicTypes.boolean}:${content ? 1 : 0}`;
}
/* Numbers */
if (typeof content === "number") {
if (isInteger(content)) {
return `${basicTypes.integer}:${content.toString()}`;
} else {
return `${basicTypes.float}:${content.toString()}`;
}
}
/* Strings */
if (typeof content === "string")
return `${basicTypes.string}:${content.length}:"${content}"`;
/** This should be unreachable */
throw new OperationError(`Encountered a non-implemented type: ${typeof content}`);
}
/**
* Recursively serialize
* @param {*} object
* @returns {string}
*/
function serialize(object) {
/* Null */
if (object == null) {
return `N;`;
}
if (typeof object !== "object") {
/* Basic types */
return `${serializeBasicTypes(object)};`;
} else if (object instanceof Array) {
/* Arrays */View on GitHub (pinned to 4290ea7539)
Solutions
- Ensure all leaf values in the JSON input are plain booleans, numbers, or strings
- Convert BigInt values to regular numbers or strings before passing them in
- Remove or stringify any Symbol-keyed or Symbol-valued properties
Example fix
// before
const data = { id: BigInt(123), name: "test" };
// after
const data = { id: Number(123), name: "test" }; Defensive patterns
Strategy: type-guard
Validate before calling
// Pre-check: ensure no unsupported primitive types
function hasUnsupportedPrimitives(obj) {
for (const v of Object.values(obj)) {
if (typeof v === 'bigint' || typeof v === 'symbol') return true;
if (typeof v === 'object' && v !== null) {
if (hasUnsupportedPrimitives(v)) return true;
}
}
return false;
} Type guard
function isSerializablePrimitive(v) {
return typeof v === 'boolean' || typeof v === 'number' || typeof v === 'string';
} Try / catch
try {
const result = chef.phpSerialize(input);
} catch (e) {
if (/non-implemented type/i.test(e.message)) {
console.error("Unsupported primitive type — convert BigInts/Symbols to strings or numbers");
} else { throw e; }
} Prevention
- Convert BigInt values to Number or String before serializing
- Remove Symbol-typed properties from the input
- Run JSON.parse(JSON.stringify(data)) to strip non-JSON-safe types
When it happens
Trigger: A JSON value that is a Symbol or BigInt reaches serializeBasicTypes because typeof returns 'symbol' or 'bigint', neither of which matches the boolean/number/string branches. A function value whose typeof is 'function' could also reach here if it bypasses the object check upstream.
Common situations: Input JSON contains a BigInt (typeof 'bigint') or Symbol (typeof 'symbol'). A JSON revival function injected non-standard primitive types. The operation is called programmatically with a parsed JSON object containing non-JSON-safe values.
Related errors
- Encountered a non-implemented type: ${typeof object}
- ${err.toString()}
- ${err.toString()}
- Unable to stringify YAML: ${err}
- End of input reached before end of script
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/868f2bedcb5c37d9.
Report an issue: GitHub.