{"record":{"id":"07eb71e59572fd87","repo":"kestra-io/kestra","slug":"unable-to-read-the-file-path","errorCode":null,"errorMessage":"Unable to read the file {path}","messagePattern":"Unable to read the file (.+?)","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/AbstractFileFunction.java","lineNumber":98,"sourceCode":"                if (str.startsWith(KESTRA_SCHEME)) {\n                    fileUri = URI.create(str);\n                    namespace = checkAllowedFileAndReturnNamespace(context, fileUri);\n                } else if (str.startsWith(LocalPath.FILE_PROTOCOL)) {\n                    fileUri = URI.create(str);\n                    namespace = checkEnabledLocalFileAndReturnNamespace(args, flow);\n                } else if (str.startsWith(Namespace.NAMESPACE_FILE_SCHEME)) {\n                    fileUri = URI.create(str);\n                    namespace = checkedAllowedNamespaceAndReturnNamespace(args, fileUri, tenantId, flow);\n                } else if (URI_PATTERN.matcher(str).matches()) {\n                    // it is an unsupported URI\n                    throw new IllegalArgumentException(SCHEME_NOT_SUPPORTED_ERROR.formatted(str));\n                } else {\n                    fileUri = URI.create(Namespace.NAMESPACE_FILE_SCHEME + \":///\" + str);\n                    namespace = (String) Optional.ofNullable(args.get(NAMESPACE)).orElse(flow.get(NAMESPACE));\n                    namespaceService.get().checkAllowedNamespace(tenantId, namespace, tenantId, flow.get(NAMESPACE));\n                }\n            } else {\n                throw new PebbleException(null, \"Unable to read the file \" + path, lineNumber, self.getName());\n            }\n            return fileFunction(context, fileUri, namespace, tenantId, args);\n        } catch (IOException | IllegalArgumentException e) { // IllegalArgumentException may be thrown for path traversal, catch it to have proper error handling\n            throw new PebbleException(e, e.getMessage(), lineNumber, self.getName());\n        }\n    }\n\n    @Override\n    public List<String> getArgumentNames() {\n        return List.of(PATH, NAMESPACE);\n    }\n\n    @Override\n    public Map<String, String> getArgumentDefaults() {\n        return Map.of(\n            PATH, \"outputs.download.uri\",\n            NAMESPACE, \"flow.namespace\"\n        );","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/AbstractFileFunction.java#L80-L116","documentation":"AbstractFileFunction.execute() branches on the runtime type of the 'path' argument: URI, String, or else. The else branch throws 'Unable to read the file ' + path when path is neither a URI nor a String (e.g. a number, list, map, or boolean).","triggerScenarios":"Calling read() with a numeric id, a list, a map, or any non-String/non-URI value: {{ read(123) }} or {{ read(outputs.task.rows) }} where rows is a list.","commonSituations":"Indexing into a list/map and passing the element assuming it is a URI string; binding path to an output field whose type is a structured object; leftover debug value.","solutions":["Ensure the path argument resolves to a String or a URI at runtime (inspect the upstream output schema).","Coerce explicitly when safe: {{ read(myVar ~ '') }} to force a string, or extract the URI field with a known path.","Avoid passing collections/scalars; read() only accepts a single file reference."],"exampleFix":"// before\n{{ read(outputs.task.id) }}\n// after\n{{ read(outputs.task.outputFiles['data']) }}","handlingStrategy":"type-guard","validationCode":"// Pebble: ensure path is a string URI before calling read\n{% if outputs.x.uri is string %}{{ read(outputs.x.uri) }}{% endif %}","typeGuard":"// Java: only accept String or URI\nif (!(path instanceof String || path instanceof URI)) {\n    throw new IllegalArgumentException(\"path must be a String or URI, got \" + path.getClass());\n}","tryCatchPattern":null,"preventionTips":["Confirm the path argument resolves to a String or URI at runtime.","Do not pass lists, maps, numbers, or booleans to read().","Inspect the upstream output schema before binding path."],"tags":["pebble","function","type-mismatch","internal-storage"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}