gchq/CyberChef · error · Error
Schema ${error}
Error message
Schema ${error} What it means
Thrown by Protobuf.updateProtoRoot when protobufjs `protobuf.parse(protoText)` raises an exception — the .proto text is syntactically invalid. The original parse error text is appended after 'Schema '.
Source
Thrown at src/core/lib/Protobuf.mjs:132
this.showUnknownFields = args[1];
this.showTypes = args[2];
return this.mergeDecodes(input);
}
/**
* Update the parsedProto, throw parsing errors
*
* @param {string} protoText
*/
static updateProtoRoot(protoText) {
try {
this.parsedProto = protobuf.parse(protoText);
if (this.parsedProto.package) {
this.parsedProto.root = this.parsedProto.root.nested[this.parsedProto.package];
}
this.updateMainMessageName();
} catch (error) {
throw new Error("Schema " + error);
}
}
/**
* Set mainMessageName to the first instance of a message defined in the schema that is not a submessage
*
*/
static updateMainMessageName() {
const messageNames = [];
const fieldTypes = [];
this.parsedProto.root.nestedArray.forEach(block => {
if (block instanceof protobuf.Type) {
messageNames.push(block.name);
this.parsedProto.root.nested[block.name].fieldsArray.forEach(field => {
fieldTypes.push(field.type);
});
}
});View on GitHub (pinned to 4290ea7539)
Solutions
- Read the appended protobufjs parse error for the line/column of the syntax fault.
- Validate the .proto with `protoc --proto_path=. --descriptor_set_out=/dev/null schema.proto` or `protobuf.parse` standalone before use.
- Ensure the schema begins with the correct `syntax` declaration.
Example fix
// before
const proto = 'message Person { string name }'; // missing semicolon
// after
const proto = 'syntax = "proto3";\nmessage Person { string name = 1; }'; Defensive patterns
Strategy: try-catch
Validate before calling
try {
protobuf.parse(protoText);
} catch (e) {
throw new Error('Proto schema is syntactically invalid: ' + e.message);
} Type guard
function isValidProto(protoText) {
try { protobuf.parse(protoText); return true; } catch { return false; }
} Try / catch
try {
return Protobuf.encode(input, [protoText]);
} catch (e) {
if (/^Schema /.test(e.message)) {
// e.message contains the protobufjs parse error with line info
}
throw e;
} Prevention
- Lint the .proto with protoc or protobuf.parse before feeding it in.
- Begin every schema with the correct `syntax` declaration.
- Avoid hand-retyping schemas; load them from a checked-in file.
When it happens
Trigger: Calling encode/decode paths with a malformed .proto: missing semicolons, unbalanced braces, illegal field labels, duplicate field numbers, invalid type references, or non-protobuf text entirely.
Common situations: Hand-typed .proto with syntax errors; copy-paste truncation; using proto2 syntax features without `syntax = "proto2"`; trailing whitespace/comments breaking older protobufjs versions.
Related errors
- Schema Error: Schema not defined
- Input Error: ${error}
- Input ${error}
- Exhausted Buffer
- Unknown type 0x${type.toString(16)}
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/73a4b4c213218891.
Report an issue: GitHub.