{"record":{"id":"6e5b009b3fb516f8","repo":"kestra-io/kestra","slug":"scheme-not-supported","errorCode":null,"errorMessage":"Scheme not supported: {}","messagePattern":"Scheme not supported: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/models/property/URIFetcher.java","lineNumber":97,"sourceCode":"     *\n     * @throws IOException if an IO error occurs\n     * @throws SecurityException if the URI points to a path that is not allowed\n     */\n    public InputStream fetch(RunContext runContext) throws IOException {\n        if (uri == null) {\n            return InputStream.nullInputStream();\n        }\n\n        // we need to first check the protocol, then create one reader by protocol\n        return switch (uri.getScheme()) {\n            case StorageContext.KESTRA_SCHEME -> runContext.storage().getFile(uri);\n            case LocalPath.FILE_SCHEME -> runContext.localPath().get(uri);\n            case Namespace.NAMESPACE_FILE_SCHEME -> {\n                var namespace = uri.getAuthority() == null ? runContext.storage().namespace() : runContext.storage().namespace(uri.getAuthority());\n                var nsFileUri = namespace.get(Path.of(uri.getPath())).uri();\n                yield runContext.storage().getFile(nsFileUri);\n            }\n            default -> throw new IllegalArgumentException(\"Scheme not supported: \" + uri.getScheme());\n        };\n    }\n}\n","sourceCodeStart":79,"sourceCodeEnd":101,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/models/property/URIFetcher.java#L79-L101","documentation":"Thrown by URIFetcher.fetchInputStream()'s switch on uri.getScheme() when the scheme passed the constructor's SUPPORTED_SCHEMES check at deserialization but the runtime RunContext does not provide a reader for it, OR more commonly when a URIFetcher is built bypassing the constructor (e.g., from an already-open URI). The default branch is a defensive fallback for any scheme not matching kestra/file/namespace. Unlike error 29, this fires at fetch time, not construction time, and the message omits the supported list.","triggerScenarios":"A URIFetcher instance is constructed via a path that skips the scheme validation, then fetchInputStream is called; a custom scheme is injected at runtime; the scheme string differs in case or whitespace from the expected constants.","commonSituations":"Reflection or test code builds a URIFetcher directly; a serialized URIFetcher round-trips through a format that drops the constructor guard; future scheme additions create an inconsistency between SUPPORTED_SCHEMES and the switch branches.","solutions":["Always construct URIFetcher via new URIFetcher(uri) or URIFetcher.of(uri) so the constructor validates the scheme.","Confirm the scheme exactly matches one of: kestra, file, namespace (lowercase).","If adding a new scheme, update BOTH SUPPORTED_SCHEMES and the switch statement."],"exampleFix":"// before (bypasses constructor guard)\nURIFetcher f = new URIFetcher(URI.create(\"ftp://h/data\")); // may pass if ftp were in list but not switch\nf.fetchInputStream(ctx); // default -> throw\n\n// after\nnew URIFetcher(URI.create(\"kestra:///data\")).fetchInputStream(ctx);","handlingStrategy":"try-catch","validationCode":"String scheme = uri.getScheme();\nif (!Set.of(StorageContext.KESTRA_SCHEME, LocalPath.FILE_SCHEME, Namespace.NAMESPACE_FILE_SCHEME).contains(scheme)) {\n    throw new IllegalArgumentException(\"Scheme not supported: \" + scheme);\n}","typeGuard":null,"tryCatchPattern":"try {\n    fetcher.fetchInputStream(runContext);\n} catch (IllegalArgumentException e) {\n    log.error(\"Unsupported scheme at fetch time: {}\", e.getMessage());\n    throw e;\n}","preventionTips":["Always construct URIFetcher via its constructor so the scheme guard runs.","Keep SUPPORTED_SCHEMES and the switch branches in sync when adding schemes."],"tags":["property","uri","fetch","storage","runtime"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}