{"record":{"id":"38149431136a7dec","repo":"kestra-io/kestra","slug":"the-fileuri-function-expects-the-revision-argu","errorCode":null,"errorMessage":"The 'fileURI' function expects the 'revision' argument to be a valid integer.","messagePattern":"The 'fileURI' function expects the 'revision' argument to be a valid integer\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/FileURIFunction.java","lineNumber":67,"sourceCode":"            case Namespace.NAMESPACE_FILE_SCHEME -> getNamespaceFileURI(path, namespace, tenantId, args);\n            default -> throw new IllegalArgumentException(SCHEME_NOT_SUPPORTED_ERROR.formatted(path));\n        };\n    }\n\n    private String getNamespaceFileURI(URI path, String namespace, String tenantId, Map<String, Object> args) throws IOException {\n        String pathStr = path.getPath();\n        if (pathStr.contains(\"../\")) {\n            throw new IllegalArgumentException(\"Path must not contain '../'\");\n        }\n        Namespace namespaceStorage = namespaceFactory.get().of(tenantId, namespace, storageInterface.get());\n        Path filePath = NamespaceFile.normalize(Path.of(pathStr));\n\n        if (args.containsKey(REVISION)) {\n            Integer revision;\n            try {\n                revision = Integer.parseInt(args.get(REVISION).toString());\n            } catch (NumberFormatException e) {\n                throw new IllegalArgumentException(\"The 'fileURI' function expects the 'revision' argument to be a valid integer.\");\n            }\n            try {\n                namespaceStorage.getFileContent(filePath, revision).close();\n            } catch (FileNotFoundException e) {\n                throw new FileNotFoundException(\"Revision \" + revision + \" of file '\" + filePath + \"' was not found in namespace '\" + namespace + \"'.\");\n            }\n            NamespaceFile namespaceFile = NamespaceFile.of(namespace, filePath, revision);\n            return namespaceFile.uri().toString();\n        } else {\n            NamespaceFile namespaceFile = namespaceStorage.get(filePath);\n            return namespaceFile.uri().toString();\n        }\n    }\n\n    @Override\n    protected String getErrorMessage() {\n        return ERROR_MESSAGE;\n    }","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/FileURIFunction.java#L49-L85","documentation":"Thrown by 'fileURI' when the optional 'revision' argument is provided but cannot be parsed by Integer.parseInt(). The function expects revision to be an integer version number of a namespace file; a non-numeric value is rejected before any storage lookup.","triggerScenarios":"Passing revision='latest', revision='v2', revision=2.5 (a float string), or revision from an input/variable that resolved to a non-integer string.","commonSituations":"Passing a semantic version label instead of the numeric revision; passing a float because an upstream expression produced a decimal; binding revision to a free-text input.","solutions":["Provide revision as an integer literal or an expression that resolves to an integer string, e.g. fileURI(path, revision=3).","If you do not need a specific revision, omit the 'revision' argument entirely to get the current version.","Validate upstream expressions that feed 'revision' to ensure they yield whole numbers."],"exampleFix":"# before\nuri: \"{{ fileURI('namespace:///f.yaml', revision='latest') }}\"\n# after - numeric revision, or omit it\nuri: \"{{ fileURI('namespace:///f.yaml', revision=2) }}\"","handlingStrategy":"validation","validationCode":"# Confirm 'revision' parses as an integer before calling fileURI().\n# {{ (revision matches '^\\\\d+$') ? fileURI(path, revision=revision) : fileURI(path) }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass 'revision' as an integer literal or an integer-yielding expression.","Omit 'revision' to get the current version when a specific one is not needed.","Validate upstream expressions that feed 'revision' produce whole numbers.","Avoid semantic version labels or floats for 'revision'."],"tags":["pebble","file","fileuri","revision","validation","namespace"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}