{"record":{"id":"e9e34ab3a783c45e","repo":"gchq/CyberChef","slug":"invalid-size-e9e34a","errorCode":null,"errorMessage":"Invalid size","messagePattern":"Invalid size","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/Shake.mjs","lineNumber":63,"sourceCode":"     * @returns {string}\n     */\n    run(input, args) {\n        const capacity = parseInt(args[0], 10),\n            size = args[1];\n        let algo;\n\n        if (size < 0)\n            throw new OperationError(\"Size must be greater than 0\");\n\n        switch (capacity) {\n            case 128:\n                algo = JSSHA3.shake128;\n                break;\n            case 256:\n                algo = JSSHA3.shake256;\n                break;\n            default:\n                throw new OperationError(\"Invalid size\");\n        }\n\n        return algo(input, size);\n    }\n\n}\n\nexport default Shake;\n","sourceCodeStart":45,"sourceCodeEnd":72,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/Shake.mjs#L45-L72","documentation":"Thrown by the Shake operation when the 'Capacity' argument is neither 128 nor 256 (after parseInt). The message says 'Invalid size' but it actually guards the capacity parameter (the SHAKE variant selection). SHAKE only has two defined instances: shake128 and shake256.","triggerScenarios":"The Capacity option is parsed to a value other than 128 or 256. The arg type is 'option' with values [\"256\",\"128\"], so this is only reachable if the option value is tampered with or the operation is invoked programmatically with an unsupported capacity.","commonSituations":"Programmatic recipe construction passing a capacity like 384 or 512 (those are SHA-3 variants, not valid SHAKE capacities); corrupted recipe JSON; a custom UI that allows free-text entry of capacity.","solutions":["Set Capacity to either 128 or 256 (the only two supported SHAKE instances).","If using SHA-3 with other bit sizes, use the 'SHA3' operation instead of Shake.","Validate the capacity against [128, 256] before invoking."],"exampleFix":"// before\nrun(input, [\"384\", 512])\n// after\nrun(input, [\"256\", 512])","handlingStrategy":"validation","validationCode":"const capacity = parseInt(args[0], 10);\nif (capacity !== 128 && capacity !== 256) {\n  throw new Error(`Unsupported Shake capacity ${capacity}; use 128 or 256.`);\n}\n// safe to invoke Shake","typeGuard":"function isValidShakeCapacity(capacity) {\n  return [128, 256].includes(parseInt(capacity, 10));\n}","tryCatchPattern":"try {\n  chef.shake(input, { capacity: \"128\", size: 256 });\n} catch (e) {\n  // 'Invalid size' here actually means invalid capacity.\n}","preventionTips":["Only use the predefined Capacity options (128, 256).","For other SHA-3 bit sizes use the SHA3 operation, not Shake.","Validate capacity against [128,256] when building recipes programmatically."],"tags":["crypto","hash","sha3","argument-validation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}