{"record":{"id":"6e6b12d5034fedc8","repo":"gchq/CyberChef","slug":"please-provide-an-input","errorCode":null,"errorMessage":"Please provide an input.","messagePattern":"Please provide an input\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/AvroToJSON.mjs","lineNumber":44,"sourceCode":"        this.inputType = \"ArrayBuffer\";\n        this.outputType = \"string\";\n        this.args = [\n            {\n                name: \"Force Valid JSON\",\n                type: \"boolean\",\n                value: true\n            }\n        ];\n    }\n\n    /**\n     * @param {ArrayBuffer} input\n     * @param {Object[]} args\n     * @returns {string}\n     */\n    async run(input, args) {\n        if (input.byteLength <= 0) {\n            throw new OperationError(\"Please provide an input.\");\n        }\n\n        const forceJSON = args[0];\n\n        return new Promise((resolve, reject) => {\n            const result = [];\n            const inpArray = new Uint8Array(input);\n            const decoder = new avro.streams.BlockDecoder();\n\n            decoder\n                .on(\"data\", function (obj) {\n                    result.push(obj);\n                })\n                .on(\"error\", function () {\n                    reject(new OperationError(\"Error parsing Avro file.\"));\n                })\n                .on(\"end\", function () {\n                    if (forceJSON) {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/AvroToJSON.mjs#L26-L62","documentation":"Thrown by AvroToJSON.run when the input ArrayBuffer has byteLength <= 0. The operation decodes Apache Avro binary container blocks via avro.streams.BlockDecoder, which requires actual bytes to parse; an empty input would produce no blocks and a meaningless result, so it is rejected up front.","triggerScenarios":"Calling the operation with no input text/file, an empty string, or an upstream operation that emitted an empty ArrayBuffer.","commonSituations":"Recipe run before pasting input; upstream 'From Base64' of an empty string; file input that failed to load producing an empty buffer.","solutions":["Provide non-empty Avro container binary data as the input.","If chaining operations, ensure the upstream step actually produced bytes (check its output length).","Load a real .avro file rather than leaving the input pane empty."],"exampleFix":"// before\nchef.avroToJSON(\"\");\n\n// after - feed actual Avro container bytes\nchef.avroToJSON(avroBinaryString);","handlingStrategy":"validation","validationCode":"function assertNonEmpty(input) {\n  const len = input?.byteLength ?? input?.length ?? 0;\n  if (len <= 0) throw new Error(\"AvroToJSON requires non-empty input\");\n}\nassertNonEmpty(input);","typeGuard":"function hasBytes(x) {\n  return (x instanceof ArrayBuffer && x.byteLength > 0)\n      || (ArrayBuffer.isView(x) && x.byteLength > 0)\n      || (typeof x === \"string\" && x.length > 0);\n}","tryCatchPattern":null,"preventionTips":["Ensure upstream operations produced bytes before AvroToJSON.","Load a real .avro file rather than leaving input empty.","Check input.byteLength > 0 before running."],"tags":["avro","input-validation","empty-input"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}