gchq/CyberChef · error · OperationError
Unrecognized capitalization scope
Error message
Unrecognized capitalization scope
What it means
Thrown by CyberChef's 'To Upper case' operation when the first argument (scope) is not one of the recognised values 'All', 'Word', 'Sentence', or 'Paragraph'. The scope string indexes a regex lookup object; an unknown key yields undefined and this guard fires. In the browser UI the value comes from a fixed dropdown so this is only reachable via the Node API or a hand-built recipe.
Source
Thrown at src/core/operations/ToUpperCase.mjs:58
run(input, args) {
if (!args || args.length === 0) {
throw new OperationError("No capitalization scope was provided.");
}
const scope = args[0];
if (scope === "All") {
return input.toUpperCase();
}
const scopeRegex = {
"Word": /(\b\w)/gi,
"Sentence": /(?:\.|^)\s*(\b\w)/gi,
"Paragraph": /(?:\n|^)\s*(\b\w)/gi
}[scope];
if (scopeRegex === undefined) {
throw new OperationError("Unrecognized capitalization scope");
}
// Use the regex to capitalize the input
return input.replace(scopeRegex, function(m) {
return m.toUpperCase();
});
}
/**
* Highlight To Upper case
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/
highlight(pos, args) {View on GitHub (pinned to 4290ea7539)
Solutions
- Set the scope argument to one of the exact strings: 'All', 'Word', 'Sentence', or 'Paragraph'.
- If building a recipe programmatically, read the allowed values from the operation's args[0].value array rather than hardcoding.
- If you want whole-string uppercasing, use scope 'All'.
Example fix
// before
chef.toUpperCase("hello", ["all"]);
// after
chef.toUpperCase("hello", ["All"]); Defensive patterns
Strategy: validation
Validate before calling
const SCOPES = ["All", "Word", "Sentence", "Paragraph"];
if (!SCOPES.includes(scope)) {
throw new Error(`Invalid scope '${scope}'. Expected one of: ${SCOPES.join(", ")}`);
} Type guard
function isValidScope(s) { return ["All","Word","Sentence","Paragraph"].includes(s); } Prevention
- Source allowed scope values from the operation's args[0].value array instead of hardcoding.
- Validate recipe args before invoking operations via the Node API.
When it happens
Trigger: Invoking ToUpperCase.run(input, [scope]) with a scope value that is not exactly 'All', 'Word', 'Sentence', or 'Paragraph' (case-sensitive). For example passing ['all'], ['Words'], undefined, or an empty array after the args.length===0 guard was bypassed.
Common situations: Calling the operation programmatically through the CyberChef Node API with a recipe whose scope arg was copied from a different version, or passing a lowercased/localised scope label. Also seen when constructing recipes dynamically and forgetting the scope element.
Related errors
- Rotor ${i} must be provided.
- Unrecognised unit
- ${this.name} length cannot exceed ${this.maxLength}.
- Invalid Public Key
- Error: Invalid output format
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/2fdd94bd1c58dd13.
Report an issue: GitHub.