{"record":{"id":"4fffc3b0c59b4ec5","repo":"kestra-io/kestra","slug":"ioexception-illegalargumentexception-e-getmessage","errorCode":null,"errorMessage":"IOException|IllegalArgumentException: e.getMessage()","messagePattern":"IOException\\|IllegalArgumentException: e\\.getMessage\\(\\)","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/AbstractFileFunction.java","lineNumber":102,"sourceCode":"                    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        );\n    }\n\n    protected abstract String getErrorMessage();\n","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/AbstractFileFunction.java#L84-L120","documentation":"This is the catch block in AbstractFileFunction.execute() that converts IOException or IllegalArgumentException into a PebbleException using e.getMessage(). It is the single rethrow point for several distinct upstream failures: path-traversal checks, URI parsing errors, the 'scheme not supported' IllegalArgumentException, the 'namespace set in two places' error, and the 'not an execution file' error. The message you see is the wrapped exception's own message.","triggerScenarios":"Any of: malformed kestra:/// URI failing URI.create; IllegalArgumentException from extractNamespace (not an execution file); IllegalArgumentException from checkedAllowedNamespaceAndReturnNamespace (namespace set twice); path-traversal rejection; IOException from the underlying fileFunction reading internal storage.","commonSituations":"Hand-typed internal storage URIs that are malformed; cross-namespace access blocked by tenancy; storage backend unreachable (IOException); namespace mismatch between argument and URI authority.","solutions":["Read the wrapped message to identify the real cause (scheme, traversal, not-an-execution-file, namespace conflict, or IO).","Use URIs produced by tasks (outputs.*.uri) rather than hand-built strings.","Verify namespace access is permitted for the executing tenant/namespace."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Read the wrapped PebbleException message to branch on root cause\ntry {\n    Object result = fileFunction.execute(args, self, context, lineNumber);\n} catch (PebbleException e) {\n    String msg = e.getMessage();\n    if (msg.contains(\"scheme not supported\")) { /* use HTTP task */ }\n    else if (msg.contains(\"not an execution file\")) { /* fix URI shape */ }\n    else if (msg.contains(\"namespace both\")) { /* remove duplicate */ }\n    else { /* IO/path-traversal: check storage + tenant access */ }\n}","preventionTips":["Use URIs from task outputs to avoid malformed-path errors.","Verify namespace/tenant access is permitted.","Inspect the wrapped message to locate the real upstream failure."],"tags":["pebble","function","exception-wrapping","internal-storage"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}