{"record":{"id":"af40dd535025d75c","repo":"gchq/CyberChef","slug":"please-provide-an-input-af40dd","errorCode":null,"errorMessage":"Please provide an input.","messagePattern":"Please provide an input\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/Bzip2Decompress.mjs","lineNumber":53,"sourceCode":"        ];\n        this.checks = [\n            {\n                \"pattern\": \"^\\\\x42\\\\x5a\\\\x68\",\n                \"flags\": \"\",\n                \"args\": []\n            }\n        ];\n    }\n\n    /**\n     * @param {byteArray} input\n     * @param {Object[]} args\n     * @returns {string}\n     */\n    async run(input, args) {\n        const [small] = args;\n        if (input.byteLength <= 0) {\n            throw new OperationError(\"Please provide an input.\");\n        }\n        if (isWorkerEnvironment()) self.sendStatusMessage(\"Loading Bzip2...\");\n        return new Promise((resolve, reject) => {\n            Bzip2().then(bzip2 => {\n                if (isWorkerEnvironment()) self.sendStatusMessage(\"Decompressing data...\");\n                const inpArray = new Uint8Array(input);\n                const bzip2cc = bzip2.decompressBZ2(inpArray, small ? 1 : 0);\n                if (bzip2cc.error !== 0) {\n                    reject(new OperationError(bzip2cc.error_msg));\n                } else {\n                    const output = bzip2cc.output;\n                    resolve(output.buffer.slice(output.byteOffset, output.byteLength + output.byteOffset));\n                }\n            });\n        });\n    }\n\n}","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/Bzip2Decompress.mjs#L35-L71","documentation":"Bzip2Decompress requires a non-empty bzip2 stream; an empty buffer cannot be a valid compressed input. The operation rejects empty input before loading the wasm module.","triggerScenarios":"Calling Bzip2Decompress.run with an input byte array whose byteLength is <= 0.","commonSituations":"Empty file fed in; upstream decode/transfer step dropped all bytes; wrong operation wired before this one.","solutions":["Supply a valid bzip2-compressed byte stream.","Skip the operation when input.byteLength === 0.","Verify the source produced the expected .bz2 bytes."],"exampleFix":"// before\nBzip2Decompress.run(emptyArray, args)\n// after\nBzip2Decompress.run(bz2Bytes, args)","handlingStrategy":"validation","validationCode":"if (!input || input.byteLength <= 0) throw new Error('Bzip2Decompress needs non-empty input');","typeGuard":"function hasBytes(arr) { return arr && arr.byteLength > 0; }","tryCatchPattern":null,"preventionTips":["Confirm the source produced a .bz2 stream.","Skip the operation for empty input.","Validate the bzip2 magic header (BZh) before decompressing."],"tags":["compression","bzip2","validation","empty-input"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}