{"record":{"id":"e577cddd5d96b523","repo":"gchq/CyberChef","slug":"please-provide-an-input-e577cd","errorCode":null,"errorMessage":"Please provide an input.","messagePattern":"Please provide an input\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/Bzip2Compress.mjs","lineNumber":53,"sourceCode":"                max: 9\n            },\n            {\n                name: \"Work factor\",\n                type: \"number\",\n                value: 30\n            }\n        ];\n    }\n\n    /**\n     * @param {ArrayBuffer} input\n     * @param {Object[]} args\n     * @returns {File}\n     */\n    async run(input, args) {\n        const [blockSize, workFactor] = 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(\"Compressing data...\");\n                const inpArray = new Uint8Array(input);\n                const bzip2cc = bzip2.compressBZ2(inpArray, blockSize, workFactor);\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/Bzip2Compress.mjs#L35-L71","documentation":"Bzip2Compress requires at least one byte of input; an empty buffer has nothing to compress and the underlying emscripten module would error. The operation rejects empty input up front with a user-facing message.","triggerScenarios":"Calling Bzip2Compress.run with an input ArrayBuffer whose byteLength is <= 0.","commonSituations":"Upstream operation produced empty output; user submitted an empty file; pipeline wired to an empty source.","solutions":["Provide non-empty input to the operation.","Guard the pipeline: skip compression when input.byteLength === 0.","Check the upstream step that should have produced data."],"exampleFix":"// before\nBzip2Compress.run(emptyBuffer, args)\n// after\nBzip2Compress.run(nonEmptyBuffer, args)","handlingStrategy":"validation","validationCode":"if (!input || input.byteLength <= 0) throw new Error('Bzip2Compress needs non-empty input');","typeGuard":"function hasBytes(buf) { return buf && buf.byteLength > 0; }","tryCatchPattern":null,"preventionTips":["Skip compression for empty payloads.","Verify the upstream operation produced output.","Guard at the pipeline boundary."],"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"}