{"record":{"id":"7c92cc92ae019b65","repo":"gchq/CyberChef","slug":"error-all-numbers-must-be-between-1-and-26","errorCode":null,"errorMessage":"Error: all numbers must be between 1 and 26.","messagePattern":"Error: all numbers must be between 1 and 26\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/A1Z26CipherDecode.mjs","lineNumber":86,"sourceCode":"    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {string}\n     */\n    run(input, args) {\n        const delim = Utils.charRep(args[0] || \"Space\");\n\n        if (input.length === 0) {\n            return \"\";\n        }\n\n        const bites = input.split(delim);\n        let latin1 = \"\";\n        for (let i = 0; i < bites.length; i++) {\n            if (bites[i] < 1 || bites[i] > 26) {\n                throw new OperationError(\"Error: all numbers must be between 1 and 26.\");\n            }\n            latin1 += Utils.chr(parseInt(bites[i], 10) + 96);\n        }\n        return latin1;\n    }\n\n}\n\nexport default A1Z26CipherDecode;\n","sourceCodeStart":68,"sourceCodeEnd":96,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/A1Z26CipherDecode.mjs#L68-L96","documentation":"A1Z26 is a substitution cipher mapping 1→a, 2→b, … 26→z. The decoder splits the input string on a chosen delimiter and expects every resulting token to be an integer in the closed range [1, 26]. This OperationError is thrown inside the run loop when any token falls outside that range (note the comparison coerces the string token to a number, so an empty token becomes 0 and also trips the guard).","triggerScenarios":"Calling run() on input where any split token is < 1 or > 26. Concretely: a value of 0, 27, or a negative; an empty token produced by a leading/trailing/doubled delimiter (e.g. \"1 2 \" or \"1  2\" with Space delim yields \"\"); a non-numeric token that coerces to 0 (though non-numeric/NaN tokens actually slip past the range check and then break Utils.chr).","commonSituations":"Input pasted with a trailing space or double spaces; wrong delimiter selected (encoder used comma but decoder uses space); numbers exceeding 26 because the data is not actually A1Z26-encoded; mixing punctuation or whitespace into the token stream.","solutions":["Normalize the input: trim it and collapse repeated delimiters before running, e.g. input.trim().replace(/ +/g, ' ').","Confirm the delimiter argument (args[0]) matches the one used when the text was encoded.","Filter out empty tokens and any value outside 1–26 if you are preprocessing a noisy source.","If the data legitimately contains numbers outside 1–26 or non-numeric symbols, A1Z26 is the wrong operation — use From Decimal or a custom parser instead."],"exampleFix":"// before: input \"1 2 27 \" throws on 27 and trailing empty token\n// after: pre-validate / sanitize\nconst clean = input.trim().split(/\\s+/).filter(t => t !== '').join(' ');\n// then run A1Z26CipherDecode on clean","handlingStrategy":"validation","validationCode":"function validateA1Z26Input(input, delim) {\n  const tokens = input.split(delim).filter(t => t.length > 0);\n  for (const t of tokens) {\n    const n = Number(t);\n    if (!Number.isInteger(n) || n < 1 || n > 26) {\n      throw new Error(`Token '${t}' is not an integer in [1,26]`);\n    }\n  }\n  return tokens.join(delim);\n}","typeGuard":"function isA1Z26Token(t) {\n  const n = Number(t);\n  return Number.isInteger(n) && n >= 1 && n <= 26;\n}","tryCatchPattern":"try {\n  runA1Z26(input, delim);\n} catch (e) {\n  if (/between 1 and 26/.test(e.message)) {\n    // sanitize and retry, or surface to user\n  } else throw e;\n}","preventionTips":["Trim and collapse repeated delimiters in the input before decoding.","Confirm the decoder delimiter matches the encoder's delimiter.","Pre-filter tokens to integers 1–26 when sourcing from noisy data."],"tags":["cipher","a1z26","validation","input-parsing"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}