{"record":{"id":"17c6fcef083718f0","repo":"elastic/elasticsearch","slug":"rendered-message-template","errorCode":null,"errorMessage":"<rendered message template>","messagePattern":"<rendered message template>","errorType":"exception","errorClass":"FailProcessorException","httpStatus":null,"severity":"error","filePath":"modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/FailProcessor.java","lineNumber":43,"sourceCode":" */\npublic final class FailProcessor extends AbstractProcessor {\n\n    public static final String TYPE = \"fail\";\n\n    private final TemplateScript.Factory message;\n\n    FailProcessor(String tag, String description, TemplateScript.Factory message) {\n        super(tag, description);\n        this.message = message;\n    }\n\n    public TemplateScript.Factory getMessage() {\n        return message;\n    }\n\n    @Override\n    public IngestDocument execute(IngestDocument document) {\n        throw new FailProcessorException(document.renderTemplate(message));\n    }\n\n    @Override\n    public String getType() {\n        return TYPE;\n    }\n\n    public static final class Factory implements Processor.Factory {\n\n        private final ScriptService scriptService;\n\n        public Factory(ScriptService scriptService) {\n            this.scriptService = scriptService;\n        }\n\n        @Override\n        public FailProcessor create(\n            Map<String, Processor.Factory> registry,","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/FailProcessor.java#L25-L61","documentation":"Thrown by FailProcessor.execute as a FailProcessorException (a specialized ElasticsearchException). The fail processor is intentionally designed to halt pipeline execution with a user-supplied message template; this is its sole behavior. The message is mustache-rendered against the document, so the exception text is dynamic. The processor exists to support conditional pipeline failure (e.g. inside an 'if' that detects bad data).","triggerScenarios":"Any pipeline containing a 'fail' processor whose 'if' condition evaluates true on the document. The 'message' option (a required field) is rendered and thrown verbatim.","commonSituations":"Intentional rejection of malformed documents (fail wrapped in an if that checks for required fields); validation pipelines that abort on policy violations; debugging leftover fail processors; condition expressions that match more than intended.","solutions":["Confirm the fail processor is intended to fire; if so, fix the document so it no longer matches the 'if' condition.","Tighten or correct the 'if' condition so only genuinely invalid documents trigger it.","Remove or comment out the fail processor if it was left from debugging.","Configure pipeline 'on_failure' to route failed documents to a dead-letter index instead of dropping them."],"exampleFix":"// before - fires for any document missing the field, including valid optional cases\n{\"fail\": {\"if\": \"ctx.tenant_id == null\", \"message\": \"missing tenant\"}}\n// after - only fail when tenant was supposed to be set\n{\"fail\": {\"if\": \"ctx.source == 'billing' && ctx.tenant_id == null\", \"message\": \"billing record missing tenant\"}}","handlingStrategy":"validation","validationCode":"// Tighten the fail processor condition so it only fires on intended cases:\n{\"fail\": {\"if\": \"ctx.doc_type == 'order' && ctx.order_id == null\", \"message\": \"order missing order_id\"}}","typeGuard":null,"tryCatchPattern":"// Pipeline on_failure lets you capture FailProcessorException and route instead of dropping:\n{\"on_failure\": [{\"set\": {\"field\": \"failure_reason\", \"value\": \"{{_ingest.on_failure_message}}\"}}, {\"index\": {\"index\": \"ingest-dlq\"}}]}","preventionTips":["Always pair fail processors with a pipeline on_failure block to preserve documents.","Make 'if' conditions as specific as possible to avoid over-matching.","Review and remove leftover fail processors from debugging."],"tags":["ingest","fail-processor","intentional-failure","validation"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}