kestra-io/kestra · error · IllegalArgumentException
`namespace` and `flowId` should only be set when `executionI
Error message
`namespace` and `flowId` should only be set when `executionId` is set.
What it means
Thrown by PluginUtilsService when executionId is null BUT namespace or flowId is set. The namespace/flowId fields are ONLY meaningful as companions to an explicit executionId; without executionId the task always operates on the current execution (sourced from flowInfo), so setting namespace/flowId is contradictory and rejected. Mirrors error 33 — together they enforce the all-or-nothing pairing of namespace/flowId with executionId.
Source
Thrown at core/src/main/java/io/kestra/core/models/tasks/runners/PluginUtilsService.java:176
String realFlowId;
if (executionId != null) {
realExecutionId = runContext.render(executionId);
if (namespace != null && flowId != null) {
realNamespace = runContext.render(namespace);
realFlowId = runContext.render(flowId);
// validate that the flow exists: a.k.a access is authorized by this namespace
runContext.acl().allowNamespace(realNamespace).check();
} else if (namespace != null || flowId != null) {
throw new IllegalArgumentException("Both `namespace` and `flowId` must be set when `executionId` is set.");
} else {
realNamespace = flowInfo.namespace();
realFlowId = flowInfo.id();
}
} else {
if (namespace != null || flowId != null) {
throw new IllegalArgumentException("`namespace` and `flowId` should only be set when `executionId` is set.");
}
realExecutionId = (String) new HashMap<>((Map<String, Object>) runContext.getVariables().get("execution")).get("id");
realNamespace = flowInfo.namespace();
realFlowId = flowInfo.id();
}
return new ExecutionInfo(realTenantId, realNamespace, realFlowId, realExecutionId);
}
/**
* @param render whether to render file contents using Pebble expressions.
*/
private static void createInputFilesInternal(RunContext runContext, Path workingDirectory, Map<String, String> inputFiles, Map<String, Object> additionalVars, boolean render)
throws Exception {
if (inputFiles != null && !inputFiles.isEmpty()) {
for (String fileName : inputFiles.keySet()) {
String finalFileName = runContext.render(fileName);
View on GitHub (pinned to 823fada927)
Solutions
- If you meant to target a specific execution, also set executionId.
- If operating on the current execution, remove namespace and flowId entirely.
- Re-read the task property docs to confirm the required combinations.
Example fix
# before
task:
namespace: "team.prod"
flowId: "myflow"
# executionId missing
# after (target current execution): remove namespace/flowId
task: {}
# OR (target specific execution): add executionId
task:
executionId: "{{ executionId }}"
namespace: "team.prod"
flowId: "myflow" Defensive patterns
Strategy: validation
Validate before calling
if (executionId == null && (namespace != null || flowId != null)) {
throw new IllegalArgumentException("`namespace` and `flowId` should only be set when `executionId` is set.");
} Type guard
function isExecutionRefValid(o: { executionId?: string; namespace?: string; flowId?: string }): boolean {
if (!o.executionId) return !o.namespace && !o.flowId;
return (!o.namespace && !o.flowId) || (!!o.namespace && !!o.flowId);
} Try / catch
try {
PluginUtilsService.executionInfo(runContext, executionId, namespace, flowId);
} catch (IllegalArgumentException e) {
log.error("namespace/flowId set without executionId: {}", e.getMessage());
} Prevention
- Omit namespace and flowId when targeting the current execution.
- Document the all-or-nothing rule for execution references.
When it happens
Trigger: A task sets namespace/flowId but omits executionId; operator assumes namespace/flowId select a target flow without an execution reference.
Common situations: Misunderstanding that namespace/flowId are subordinate to executionId; leftover config from a different task shape.
Related errors
- Both `namespace` and `flowId` must be set when `executionId`
- Invalid outputFile (only relative path is supported) for pat
- Invalid `files` properties with type '{}'
- Path must not contain '../'
- The 'fileURI' function expects the 'revision' argument to be
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/8fce8ac2b6a522e4.
Report an issue: GitHub.