{"record":{"id":"381ce6bd551b63cf","repo":"gchq/CyberChef","slug":"input-error","errorCode":null,"errorMessage":"Input ${error}","messagePattern":"Input \\$\\{error\\}","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/lib/Protobuf.mjs","lineNumber":201,"sourceCode":"            const packageDecode = message.toObject(message.decode(input), {\n                bytes: String,\n                longs: Number,\n                enums: String,\n                defaults: true\n            });\n            const output = {};\n\n            if (this.showUnknownFields) {\n                output[message.name] = packageDecode;\n                output[\"Unknown Fields\"] = this.compareFields(rawDecode, message);\n                return output;\n            } else {\n                return packageDecode;\n            }\n\n        } catch (error) {\n            if (message) {\n                throw new Error(\"Input \" + error);\n            } else {\n                return rawDecode;\n            }\n        }\n    }\n\n    /**\n     * Replace fieldnames with fieldname and type\n     *\n     * @param {Object} schemaRoot\n     * @returns {Object}\n     */\n    static appendTypesToFieldNames(schemaRoot) {\n        for (const block of schemaRoot.nestedArray) {\n            if (block instanceof protobuf.Type) {\n                for (const [fieldName, fieldData] of Object.entries(block.fields)) {\n                    schemaRoot.nested[block.name].remove(block.fields[fieldName]);\n                    schemaRoot.nested[block.name].add(new protobuf.Field(`${fieldName} (${fieldData.type})`, fieldData.id, fieldData.type, fieldData.rule));","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/lib/Protobuf.mjs#L183-L219","documentation":"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 '.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the appended decode error to find the offending field.","Confirm the .proto matches how the data was encoded (same message, same field numbers/types).","Fall back to raw decode by omitting the schema, or pick the correct main message."],"exampleFix":"// before: data encoded as MessageB but schema's first message is MessageA\nProtobuf.mergeDecodes(bytes); // throws Input ...\n// after: reorder schema so the matching message is first, or use raw decode\nconst pb = new Protobuf(bytes); return pb._parse();","handlingStrategy":"fallback","validationCode":"Protobuf.updateProtoRoot(protoText);\nconst message = Protobuf.parsedProto.root.nested[Protobuf.mainMessageName];\nif (!message) {\n  // no schema match — fall back to raw decode instead of risking Input error\n  return new Protobuf(input)._parse();\n}","typeGuard":"function dataMatchesMessage(message, bytes) {\n  try { message.decode(bytes); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  return Protobuf.mergeDecodes(input);\n} catch (e) {\n  if (/^Input /.test(e.message)) {\n    return new Protobuf(input)._parse(); // raw schemaless fallback\n  }\n  throw e;\n}","preventionTips":["Confirm the .proto and mainMessageName match the encoding of the bytes.","Keep a raw-decode fallback for data of unknown provenance.","Re-encode a known sample with the schema and compare before trusting decode."],"tags":["protobuf","schema","decode","validation","input-error"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}