gchq/CyberChef · error · Error

Input ${error}

Error message

Input ${error}

What it means

Thrown by Protobuf.mergeDecodes when a schema message was resolved (so `message` is truthy) but `message.decode(input)` raised — i.e. the raw bytes do not conform to the selected message type. The underlying protobufjs decode error is appended after 'Input '.

Source

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

            const packageDecode = message.toObject(message.decode(input), {
                bytes: String,
                longs: Number,
                enums: String,
                defaults: true
            });
            const output = {};

            if (this.showUnknownFields) {
                output[message.name] = packageDecode;
                output["Unknown Fields"] = this.compareFields(rawDecode, message);
                return output;
            } else {
                return packageDecode;
            }

        } catch (error) {
            if (message) {
                throw new Error("Input " + error);
            } else {
                return rawDecode;
            }
        }
    }

    /**
     * Replace fieldnames with fieldname and type
     *
     * @param {Object} schemaRoot
     * @returns {Object}
     */
    static appendTypesToFieldNames(schemaRoot) {
        for (const block of schemaRoot.nestedArray) {
            if (block instanceof protobuf.Type) {
                for (const [fieldName, fieldData] of Object.entries(block.fields)) {
                    schemaRoot.nested[block.name].remove(block.fields[fieldName]);
                    schemaRoot.nested[block.name].add(new protobuf.Field(`${fieldName} (${fieldData.type})`, fieldData.id, fieldData.type, fieldData.rule));

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Read the appended decode error to find the offending field.
  2. Confirm the .proto matches how the data was encoded (same message, same field numbers/types).
  3. Fall back to raw decode by omitting the schema, or pick the correct main message.

Example fix

// before: data encoded as MessageB but schema's first message is MessageA
Protobuf.mergeDecodes(bytes); // throws Input ...
// after: reorder schema so the matching message is first, or use raw decode
const pb = new Protobuf(bytes); return pb._parse();
Defensive patterns

Strategy: fallback

Validate before calling

Protobuf.updateProtoRoot(protoText);
const message = Protobuf.parsedProto.root.nested[Protobuf.mainMessageName];
if (!message) {
  // no schema match — fall back to raw decode instead of risking Input error
  return new Protobuf(input)._parse();
}

Type guard

function dataMatchesMessage(message, bytes) {
  try { message.decode(bytes); return true; } catch { return false; }
}

Try / catch

try {
  return Protobuf.mergeDecodes(input);
} catch (e) {
  if (/^Input /.test(e.message)) {
    return new Protobuf(input)._parse(); // raw schemaless fallback
  }
  throw e;
}

Prevention

When it happens

Trigger: Decoding protobuf bytes against a schema where wire data is truncated, a field number/type mismatches the schema, a varint overflows, or the bytes were produced for a different message type than mainMessageName.

Common situations: Wrong .proto selected for the data; bytes were encoded with a different message layout; truncated network capture; decoding a sub-message payload as the top-level message.

Related errors


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