gchq/CyberChef · error · Error

Input Error: ${error}

Error message

Input Error: ${error}

What it means

Thrown by Protobuf.encode when protobufjs `message.verify(input)` returns a non-empty error string — i.e. the supplied JSON/object does not satisfy the schema for the resolved message type. The original protobufjs message is appended.

Source

Thrown at src/core/lib/Protobuf.mjs:99

    /**
     * Encode input JSON according to the given schema
     *
     * @param {Object} input
     * @param {Object []} args
     * @returns {Object}
     */
    static encode(input, args) {
        this.updateProtoRoot(args[0]);
        if (!this.mainMessageName) {
            throw new Error("Schema Error: Schema not defined");
        }
        const message = this.parsedProto.root.nested[this.mainMessageName];

        // Convert input into instance of message, and verify instance
        input = message.fromObject(input);
        const error = message.verify(input);
        if (error) {
            throw new Error("Input Error: " + error);
        }
        // Encode input
        const output = message.encode(input).finish();
        return new Uint8Array(output).buffer;
    }

    /**
     * Parse Protobuf data
     *
     * @param {byteArray} input
     * @returns {Object}
     */
    static decode(input, args) {
        this.updateProtoRoot(args[0]);
        this.showUnknownFields = args[1];
        this.showTypes = args[2];
        return this.mergeDecodes(input);
    }

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Read the appended protobufjs message — it names the offending field and the constraint violated.
  2. Align the input JSON to the schema: correct types, fill required fields, remove unknown fields.
  3. Validate with `message.verify(input)` separately first and log its full output before encode.

Example fix

// before: schema expects int32 age, input has string
Protobuf.encode({name:'A', age:'30'}, [proto]);
// after
Protobuf.encode({name:'A', age:30}, [proto]);
Defensive patterns

Strategy: validation

Validate before calling

Protobuf.updateProtoRoot(protoText);
const message = Protobuf.parsedProto.root.nested[Protobuf.mainMessageName];
const obj = message.fromObject(input);
const verifyErr = message.verify(obj);
if (verifyErr) throw new Error('Input does not match schema: ' + verifyErr);
return Protobuf.encode(input, [protoText]);

Type guard

function inputMatchesMessage(message, input) {
  return !message.verify(message.fromObject(input));
}

Try / catch

try {
  return Protobuf.encode(input, [protoText]);
} catch (e) {
  if (/^Input Error:/.test(e.message)) {
    // e.message after 'Input Error: ' names the failing field
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling encode with input missing required fields, wrong field types (e.g. string where int32 is expected), out-of-range enum values, malformed bytes fields, or extra fields that violate schema under strict parsing.

Common situations: Mismatch between user-supplied JSON and the .proto (field renamed, type changed, required field missing in proto2); sending numbers as strings; invalid enum names; bytes fields not provided as base64/ArrayBuffer.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/cdf20e54007c8efd. Report an issue: GitHub.