{"record":{"id":"5696f6a95bdd0961","repo":"kestra-io/kestra","slug":"the-subflow-function-expects-the-arguments-name","errorCode":null,"errorMessage":"The 'subflow' function expects the arguments 'namespace' and 'id'.","messagePattern":"The 'subflow' function expects the arguments 'namespace' and 'id'\\.","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/SubflowFunction.java","lineNumber":117,"sourceCode":"    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) {\n        // The call blocks until the subflow terminates: only allow it where rendering happens on a\n        // blocking-friendly thread (flow-input rendering on the webserver). A top-level 'taskrun' or\n        // 'trigger' variable means we are rendering a task or trigger property, which may run on a worker.\n        if (context.getVariable(\"taskrun\") != null || context.getVariable(\"trigger\") != null) {\n            throw new PebbleException(\n                null, \"The 'subflow' function can only be used at flow-input render time (e.g. an input's 'values'); it is not supported inside task or trigger properties.\", lineNumber,\n                self.getName()\n            );\n        }\n\n        String namespace = (String) args.get(NAMESPACE_ARG);\n        String id = (String) args.get(ID_ARG);\n        if (namespace == null || id == null) {\n            throw new PebbleException(null, \"The 'subflow' function expects the arguments 'namespace' and 'id'.\", lineNumber, self.getName());\n        }\n\n        Map<String, String> flow = (Map<String, String>) context.getVariable(\"flow\");\n        if (flow == null) {\n            throw new PebbleException(\n                null, \"The 'subflow' function can only be used in a flow context (e.g. an input's 'values'); the caller flow could not be resolved.\", lineNumber, self.getName()\n            );\n        }\n        String tenantId = flow.get(\"tenantId\");\n        String callerNamespace = flow.get(NAMESPACE_ARG);\n        String callerId = flow.get(\"id\");\n\n        Optional<Integer> revision = Optional.ofNullable(args.get(REVISION_ARG)).map(r -> ((Number) r).intValue());\n        Map<String, Object> rawInputs = (Map<String, Object>) args.get(INPUTS_ARG);\n        Map<String, Object> inputs = rawInputs != null ? rawInputs : Map.of();\n\n        List<Label> labels = buildLabels(args.get(LABELS_ARG), self, lineNumber);\n        Duration timeout = resolveTimeout(args.get(TIMEOUT_ARG), self, lineNumber);","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/SubflowFunction.java#L99-L135","documentation":"The subflow() function requires both 'namespace' and 'id' arguments to identify the target flow. If either resolves to null, the function throws before attempting any flow lookup. These are the first arguments validated after the context check.","triggerScenarios":"Calling {{ subflow(namespace='company.team') }} without id. Passing null or an empty variable for either argument. A dynamic expression for namespace or id that evaluates to null because the upstream variable does not exist.","commonSituations":"Typo in argument names (e.g., flowId instead of id, ns instead of namespace). A variable used for namespace/id that is undefined or null at render time. Partially written template during development.","solutions":["Provide both arguments explicitly: {{ subflow(namespace='company.team', id='my_flow') }}.","Verify the argument names are exactly 'namespace' and 'id' (not 'flowId', 'flowNamespace', 'ns').","Ensure any dynamic expressions for these arguments resolve to non-null strings."],"exampleFix":"# before — missing 'id' argument\n{{ subflow(namespace='company.team') }}\n{{ subflow(namespace='company.team', flowId='child') }}\n\n# after — both required arguments present\n{{ subflow(namespace='company.team', id='child') }}","handlingStrategy":"validation","validationCode":"# Always provide both 'namespace' and 'id' arguments.\n# Correct: {{ subflow(namespace='company.team', id='child') }}\n# Verify dynamic expressions resolve to non-null:\n{% if inputs.target_ns is not empty and inputs.target_id is not empty %}\n  {{ subflow(namespace=inputs.target_ns, id=inputs.target_id) }}\n{% else %}\n  MISSING_NAMESPACE_OR_ID\n{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always specify both namespace and id arguments.","Verify argument names are exactly 'namespace' and 'id' (not 'flowId', 'ns').","Ensure dynamic expressions for these arguments resolve to non-null strings.","Test with hardcoded values first to isolate dynamic resolution issues."],"tags":["pebble","subflow","arguments","validation","required"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}