{"record":{"id":"c55c08fb07e2141f","repo":"neo4j/neo4j","slug":"invalid-uri-provided","errorCode":null,"errorMessage":"Invalid URI provided: ","messagePattern":"Invalid URI provided: ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"community/cloud/src/main/java/org/neo4j/cloud/storage/SchemeFileSystemAbstraction.java","lineNumber":150,"sourceCode":"        }\n        // no scheme: it's a local file path that the fallback can handle\n        return true;\n    }\n\n    @Override\n    public Path resolve(URI resource) throws IOException {\n        return internalResolve(resource.getScheme(), () -> resource);\n    }\n\n    @Override\n    public Path resolve(String resource) throws IOException {\n        final var matcher = SCHEME.matcher(resource);\n        if (matcher.matches()) {\n            return internalResolve(matcher.group(1), () -> {\n                try {\n                    return new URI(resource);\n                } catch (URISyntaxException ex) {\n                    throw new IOException(\"Invalid URI provided: \" + resource, ex);\n                }\n            });\n        }\n\n        return Path.of(resource);\n    }\n\n    @Override\n    public StoreChannel open(Path fileName, Set<OpenOption> options) throws IOException {\n        if (fileName instanceof StoragePath path) {\n            //noinspection\n            return internalOpen(path, options);\n        }\n\n        return fs.open(fileName, options);\n    }\n\n    @Override","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/neo4j/neo4j/blob/f213380f812b820a1b312e2ea52cb3d8f1931ccc/community/cloud/src/main/java/org/neo4j/cloud/storage/SchemeFileSystemAbstraction.java#L132-L168","documentation":"SchemeFileSystemAbstraction.resolve(String) first matches the string against a URI scheme pattern (scheme:...). If the pattern matches, the string is parsed with new URI(resource); a URISyntaxException means the text looks like a schemed URI but is malformed, so the abstraction wraps the failure in this IOException instead of silently treating it as a local path.","triggerScenarios":"Calling fileSystemAbstraction.resolve(resource) with a string that starts with a scheme-like prefix but contains illegal URI characters — unencoded spaces, brackets, or invalid escapes — e.g. \"s3://bucket/my file.txt\" or \"gs://bucket/a[b].csv\", or a syntactically broken scheme such as \"1abc://x\".","commonSituations":"Passing cloud URLs copy-pasted from browsers or consoles (spaces, unicode, query strings) without URL-encoding; Windows drive letters like \"C:\\data\" accidentally matching the scheme regex; environment-specific path configs where a value was meant as a local path but contains a colon on the left.","solutions":["URL-encode the path portion of the URI (spaces -> %20, brackets -> %5B/%5D) before calling resolve","Construct a java.net.URI first with proper encoding and call resolve(URI) instead of resolve(String)","If the value is genuinely a local path that merely resembles a scheme, rename or pass it via Path.of(...) directly"],"exampleFix":"// before\nvar path = fs.resolve(\"s3://bucket/my file.txt\"); // throws IOException\n\n// after\nvar path = fs.resolve(\"s3://bucket/my%20file.txt\");\n// or\nvar path = fs.resolve(URI.create(\"s3://bucket/my%20file.txt\"));","handlingStrategy":"validation","validationCode":"private static final java.util.regex.Pattern SCHEME_LIKE = Pattern.compile(\"^([A-Za-z][A-Za-z0-9+.-]*):.*\");\n\nboolean willParse(String resource) {\n    var m = SCHEME_LIKE.matcher(resource);\n    return !m.matches() || isValidUri(resource);\n}\n\nboolean isValidUri(String s) {\n    try { new URI(s); return true; } catch (URISyntaxException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"catch (IOException e) { if (e.getCause() instanceof URISyntaxException use) ... } — unwrap and report the exact syntax error position from URISyntaxException to the user/config key.","preventionTips":["Always URL-encode the path component of cloud URIs (spaces, brackets, non-ASCII)","Prefer resolve(URI) built with URI.create over resolve(String) for schemed resources","Validate configured URIs at startup with new URI(value) and fail fast with the config key name"],"tags":["filesystem","uri","cloud-storage","validation"],"backgroundTag":null,"analyzedSha":"f213380f812b820a1b312e2ea52cb3d8f1931ccc","analyzedAt":"2026-08-14T15:32:33.859Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}