{"record":{"id":"95f0ef618d7a553c","repo":"gchq/CyberChef","slug":"invalid-length-type","errorCode":null,"errorMessage":"Invalid length type","messagePattern":"Invalid length type","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/GenerateLoremIpsum.mjs","lineNumber":65,"sourceCode":"    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {string}\n     */\n    run(input, args) {\n        const [length, lengthType] = args;\n        checkLimits(lengthType, length);\n        switch (lengthType) {\n            case \"Paragraphs\":\n                return GenerateParagraphs(length);\n            case \"Sentences\":\n                return GenerateSentences(length);\n            case \"Words\":\n                return GenerateWords(length);\n            case \"Bytes\":\n                return GenerateBytes(length);\n            default:\n                throw new OperationError(\"Invalid length type\");\n\n        }\n    }\n\n}\n\nexport default GenerateLoremIpsum;\n\n/**\n * check combined validity of lengthType and length arguments\n * @param {string} lengthType\n * @param {number} length\n * @throws {OperationError}\n */\nfunction checkLimits(lengthType, length) {\n    if (length < 1) {\n        throw new OperationError(\"Length must be greater than 0\");\n    }","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/GenerateLoremIpsum.mjs#L47-L83","documentation":"Thrown by GenerateLoremIpsum.run() when lengthType is not one of Paragraphs, Sentences, Words, or Bytes. This is the fallback of the dispatch switch that selects the generator function. It is an enum-validation error on the lengthType argument.","triggerScenarios":"Passing a lengthType value outside the four recognized strings — e.g. 'Characters', 'Lines', a typo, or undefined/null when building a recipe programmatically.","commonSituations":"Recipe built in code without setting lengthType, or a dropdown enum value changed between CyberChef versions.","solutions":["Set lengthType to one of: Paragraphs, Sentences, Words, Bytes.","If building recipes in code, validate lengthType against the allowed set before invoking."],"exampleFix":"// before\nargs = [50, \"Lines\"];\n// after\nargs = [50, \"Sentences\"];","handlingStrategy":"type-guard","validationCode":"const VALID_LENGTH_TYPES = [\"Paragraphs\", \"Sentences\", \"Words\", \"Bytes\"];\nif (!VALID_LENGTH_TYPES.includes(lengthType)) {\n  // reject before invoking\n}","typeGuard":"function isLengthType(t) {\n  return [\"Paragraphs\", \"Sentences\", \"Words\", \"Bytes\"].includes(t);\n}","tryCatchPattern":null,"preventionTips":["Constrain the lengthType control to the four known values.","Validate programmatically-built recipes against the known enum."],"tags":["lorem-ipsum","argument-validation","enum","user-input"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}