{"record":{"id":"4312637451f29628","repo":"gchq/CyberChef","slug":"no-capitalization-scope-was-provided","errorCode":null,"errorMessage":"No capitalization scope was provided.","messagePattern":"No capitalization scope was provided\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ToUpperCase.mjs","lineNumber":42,"sourceCode":"        this.inputType = \"string\";\n        this.outputType = \"string\";\n        this.args = [\n            {\n                \"name\": \"Scope\",\n                \"type\": \"option\",\n                \"value\": [\"All\", \"Word\", \"Sentence\", \"Paragraph\"]\n            }\n        ];\n    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {string}\n     */\n    run(input, args) {\n        if (!args || args.length === 0) {\n            throw new OperationError(\"No capitalization scope was provided.\");\n        }\n\n        const scope = args[0];\n\n        if (scope === \"All\") {\n            return input.toUpperCase();\n        }\n\n        const scopeRegex = {\n            \"Word\": /(\\b\\w)/gi,\n            \"Sentence\": /(?:\\.|^)\\s*(\\b\\w)/gi,\n            \"Paragraph\": /(?:\\n|^)\\s*(\\b\\w)/gi\n        }[scope];\n\n        if (scopeRegex === undefined) {\n            throw new OperationError(\"Unrecognized capitalization scope\");\n        }\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ToUpperCase.mjs#L24-L60","documentation":"To Upper Case requires a capitalization scope argument ('All', 'Word', 'Sentence', or 'Paragraph') that selects which portions of the input to uppercase. The guard throws when args is missing or empty, because without a scope the operation has no defined behaviour.","triggerScenarios":"Calling the operation with no args, an empty args array, or null args — typically only possible via a programmatic recipe or a malformed config, since the UI always supplies a default option.","commonSituations":"Programmatically constructing a recipe and omitting the scope argument; a corrupted recipe config that lost the argument list; calling the operation directly in tests without args.","solutions":["Provide a scope argument: 'All', 'Word', 'Sentence', or 'Paragraph'.","When building recipes programmatically, always include the args array with the default 'All'.","Re-add the operation through the UI to restore its default arguments."],"exampleFix":"// before: op.run(input, [])               -> throws\n// after:  op.run(input, [\"All\"])            -> uppercases the whole string","handlingStrategy":"validation","validationCode":"if (!Array.isArray(args) || args.length === 0) {\n  throw new Error(\"To Upper Case requires a scope argument\");\n}","typeGuard":"const hasScope = args => Array.isArray(args) && args.length > 0 && [\"All\",\"Word\",\"Sentence\",\"Paragraph\"].includes(args[0]);","tryCatchPattern":"try { toUpperCase(input, args); }\ncatch (e) { if (/capitalization scope/.test(e.message)) { args = [\"All\"]; } else throw e; }","preventionTips":["Always include a scope argument when constructing the recipe in code.","Default to 'All' when unsure.","Re-add the operation through the UI to restore defaults."],"tags":["validation","argument","text","uppercase"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}