gchq/CyberChef · error · OperationError
${e}
Error message
${e} What it means
The Template operation compiles a Handlebars template string and renders it against the JSON input. Any error raised by Handlebars.compile() or by invoking the compiled template — syntax errors, unknown helpers, type errors during rendering — is caught and rethrown as an OperationError whose message is the original error.
Source
Thrown at src/core/operations/Template.mjs:48
name: "Template definition (.handlebars)",
type: "text",
value: ""
}
];
}
/**
* @param {JSON} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const [templateStr] = args;
try {
const template = Handlebars.compile(templateStr);
return template(input);
} catch (e) {
throw new OperationError(e);
}
}
}
export default Template;
View on GitHub (pinned to 4290ea7539)
Solutions
- Validate the template syntax in an external Handlebars playground before pasting it in.
- Ensure every block helper {{#x}} has a matching {{/x}}.
- Remove references to helpers that are not part of Handlebars core.
- Feed valid JSON input that matches the fields the template references.
Example fix
// before: template = "{{#each items}}{{name}}{{/loop}}" (mismatched block name)
// after: template = "{{#each items}}{{name}}{{/each}}" Defensive patterns
Strategy: try-catch
Validate before calling
let compiled;
try { compiled = Handlebars.compile(templateStr); }
catch (e) { throw new Error(`Template syntax invalid: ${e.message}`); }
return compiled(jsonInput); Type guard
function isCompilableTemplate(tpl) {
try { Handlebars.precompile(tpl); return true; } catch { return false; }
} Try / catch
try { chef.Template(jsonInput, [templateStr]); }
catch (e) { if (/Parse error|Expecting/.test(e.message)) { /* fix template syntax */ } else throw e; } Prevention
- Precompile templates in isolation to surface syntax errors.
- Match every {{#block}} with its {{/block}}.
- Only reference Handlebars core helpers unless custom ones are registered.
When it happens
Trigger: A malformed Handlebars template (unbalanced braces, unclosed block like {{#each}} without {{/each}}, or an unterminated expression); referencing a helper that is not registered; or rendering a template whose partial/helper expects a type the JSON input does not provide.
Common situations: Authoring a template with a typo in block syntax; using a custom helper that Handlebars does not ship; passing non-object JSON that the template indexes into.
Related errors
- Invalid recipe
- ${err.toString()}
- Unable to parse CSV: ${err}
- No "r" value in the signature JSON
- No "s" value in the signature JSON
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/e34288024dfbcccb.
Report an issue: GitHub.