{"record":{"id":"ba0587751f3f689d","repo":"kestra-io/kestra","slug":"unable-to-read-the-file-path-as-it-is-not-an-e","errorCode":null,"errorMessage":"Unable to read the file '{path}' as it is not an execution file","messagePattern":"Unable to read the file '(.+?)' as it is not an execution file","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/AbstractFileFunction.java","lineNumber":200,"sourceCode":"        if (args.get(NAMESPACE) != null && nsFileUri.getAuthority() != null) {\n            throw new IllegalArgumentException(\"You cannot set a namespace both as the function argument and inside the URI\");\n        }\n\n        // we will transform nsfile URI into a kestra URI so it is handled seamlessly by all functions\n        String customNs = Optional.ofNullable((String) args.get(NAMESPACE)).orElse(nsFileUri.getAuthority());\n        if (customNs != null) {\n            namespaceService.get().checkAllowedNamespace(tenantId, customNs, tenantId, flow.get(NAMESPACE));\n        }\n        return Optional.ofNullable(customNs).orElse(flow.get(NAMESPACE));\n    }\n\n    @VisibleForTesting\n    String extractNamespace(URI path) {\n        // Extract namespace from the path, it should be of the form: kestra:///{namespace}/{flowId}/executions/{executionId}/tasks/{taskId}/{taskRunId}/{fileName}'\n        // To extract the namespace, we must do it step by step as namespace and taskId can contain the words 'executions' and 'tasks'\n        String namespace = path.toString().substring(KESTRA_SCHEME.length());\n        if (!EXECUTION_FILE.matcher(namespace).matches()) {\n            throw new IllegalArgumentException(\"Unable to read the file '\" + path + \"' as it is not an execution file\");\n        }\n        // 1. remove everything after tasks\n        namespace = namespace.substring(0, namespace.lastIndexOf(\"/tasks/\"));\n        // 2. remove everything after executions\n        namespace = namespace.substring(0, namespace.lastIndexOf(\"/executions/\"));\n        // 3. remove the flowId\n        namespace = namespace.substring(0, namespace.lastIndexOf('/'));\n        // 4. replace '/' with '.'\n        namespace = namespace.replace(\"/\", \".\");\n\n        return namespace;\n    }\n}\n","sourceCodeStart":182,"sourceCodeEnd":214,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/AbstractFileFunction.java#L182-L214","documentation":"extractNamespace() parses a kestra:/// internal storage URI expecting the shape .../executions/{executionId}/tasks/{taskId}/{taskRunId}/{fileName}. If the path after the kestra:// scheme does not match the EXECUTION_FILE regex, it throws IllegalArgumentException ('Unable to read the file ... as it is not an execution file'), wrapped by the catch into a PebbleException.","triggerScenarios":"Pointing read() at a kestra:/// URI that is a namespace file (/_files/...) or a trigger file, or a hand-built URI missing the executions/.../tasks/.../... structure, when the code path requires an execution-scoped file.","commonSituations":"Cross-namespace access to a file whose URI lacks the execution/tasks segments; truncated or copy-pasted internal storage URIs; confusing namespace files with execution files.","solutions":["Use a URI produced by a task output (outputs.*.uri) so the structure is guaranteed correct.","For namespace files use the namespace:// scheme instead of a kestra:/// execution URI.","Verify the URI contains /executions/<id>/tasks/<id>/<runId>/<file>."],"exampleFix":"// before\n{{ read('kestra:///company.team/_files/data.txt') }}\n// after\n{{ read('namespace:///company.team/data.txt') }}","handlingStrategy":"validation","validationCode":"// Pebble: use the right scheme for the file type\n{{ read('namespace:///company.team/data.txt') }}  // for namespace files\n{{ read(outputs.task.uri) }}                       // for execution files","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use URIs produced by task outputs so the execution-file shape is guaranteed.","Use namespace:// for namespace files instead of a kestra:/// path.","Confirm the URI contains /executions/<id>/tasks/<id>/<runId>/<file>."],"tags":["pebble","function","uri","internal-storage","namespace"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}