{"record":{"id":"6c8a1d49f2810a04","repo":"kestra-io/kestra","slug":"cannot-run-the-invalid-flow-s-s-s","errorCode":null,"errorMessage":"Cannot run the invalid flow '%s'.'%s': %s","messagePattern":"Cannot run the invalid flow '(.+?)'\\.'(.+?)': (.+?)","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/SubflowFunction.java","lineNumber":164,"sourceCode":"        DEPTH.set(depth + 1);\n        try {\n            // ACL is scoped to the caller flow (callerNamespace/callerId), matching the Subflow task trust model:\n            // if the caller flow may reference the target, so may subflow(). Note this is reachable at execute-form\n            // render time, not only at execution time, so anyone able to open the form triggers this resolution.\n            // resolved for runtime so a governance rejection surfaces as a FlowWithException here, rather than\n            // becoming a created-then-failed execution\n            FlowWithSource targetFlow = flowMetaStore.get()\n                .findByIdFromTaskForRuntime(tenantId, namespace, id, revision, tenantId, callerNamespace, callerId)\n                .orElseThrow(\n                    () -> new PebbleException(\n                        null, \"Unable to find flow '\" + namespace + \"'.'\" + id + \"'\"\n                            + revision.map(r -> \" with revision \" + r).orElse(\"\") + \".\",\n                        lineNumber, self.getName()\n                    )\n                );\n\n            if (targetFlow instanceof FlowWithException fwe) {\n                throw new PebbleException(null, \"Cannot run the invalid flow '\" + namespace + \"'.'\" + id + \"': \" + fwe.getException(), lineNumber, self.getName());\n            }\n            if (targetFlow.isDisabled()) {\n                throw new PebbleException(null, \"Cannot run the disabled flow '\" + namespace + \"'.'\" + id + \"'.\", lineNumber, self.getName());\n            }\n\n            Execution execution;\n            try {\n                execution = Execution.newExecution(\n                    targetFlow,\n                    (f, e) -> flowInputOutput.get().readExecutionInputs(f, e, inputs),\n                    labels,\n                    Optional.empty()\n                );\n            } catch (Exception e) {\n                throw new PebbleException(e, \"Invalid inputs for subflow '\" + namespace + \"'.'\" + id + \"': \" + e.getMessage(), lineNumber, self.getName());\n            }\n\n            Execution terminated;","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/SubflowFunction.java#L146-L182","documentation":"After resolving the target flow by namespace/id/revision, the subflow() function checks whether the returned FlowWithSource is actually a FlowWithException — meaning the flow exists but failed validation and is marked as invalid (it has a stored exception message). In this state the flow cannot be executed, and the function surfaces the original validation exception so the user knows what is wrong with the target flow.","triggerScenarios":"The target flow has a YAML syntax error, a missing required plugin, an invalid task configuration, or another validation failure that makes it unloadable as a runnable flow. Calling subflow(namespace='ns', id='broken_flow') where 'broken_flow' exists but is in an error state.","commonSituations":"The target flow was recently edited and has a validation error that hasn't been fixed yet. A plugin referenced by the target flow is missing from the classpath. A dependency between flows means an upstream edit broke a downstream flow used in a subflow() call.","solutions":["Open the target flow in the Kestra UI and fix the validation error indicated by the exception message.","Ensure all plugins referenced by the target flow are installed.","If the target flow was deleted or renamed, update the subflow() call to reference the correct flow.","Validate the target flow YAML with the Kestra flow validator before deploying."],"exampleFix":"# before — target flow 'child' is invalid (has a validation error)\n{{ subflow(namespace='company.team', id='child') }}\n\n# Fix the target flow 'child' in the UI/editor — the exception message tells you what is wrong.\n# Then the subflow() call will succeed.\n# No Pebble-level fix exists; the target flow itself must be corrected.","handlingStrategy":"validation","validationCode":"# Before calling subflow() on a target flow, verify it is valid:\n# 1. Open the target flow in the Kestra UI — if it shows a validation error, fix it first.\n# 2. Use the Kestra API to check the flow's status:\n#    GET /api/v1/flows/{namespace}/{id} — a FlowWithException will include the exception field.\n# There is no Pebble-level pre-check; the target flow must be valid by construction.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fix validation errors in target flows before other flows reference them via subflow().","Set up CI/CD validation for all flows to catch invalid flow definitions before deployment.","Ensure all required plugins are installed on all Kestra instances.","Monitor for FlowWithException states after deployments."],"tags":["pebble","subflow","flow-validation","invalid-flow"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}