{"record":{"id":"ab789508ba901e1f","repo":"oracle/graal","slug":"query-component-present","errorCode":null,"errorMessage":"Query component present","messagePattern":"Query component present","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/TruffleFileSystemProvider.java","lineNumber":94,"sourceCode":"        return SCHEME;\n    }\n\n    private void checkUri(URI uri) {\n        if (!uri.getScheme().equalsIgnoreCase(getScheme())) {\n            throw new IllegalArgumentException(\"URI does not match this provider\");\n        }\n        if (uri.getRawAuthority() != null) {\n            throw new IllegalArgumentException(\"Authority component present\");\n        }\n        String path = uri.getPath();\n        if (path == null) {\n            throw new IllegalArgumentException(\"Path component is undefined\");\n        }\n        if (!path.equals(\"/\")) {\n            throw new IllegalArgumentException(\"Path component should be '/'\");\n        }\n        if (uri.getRawQuery() != null) {\n            throw new IllegalArgumentException(\"Query component present\");\n        }\n        if (uri.getRawFragment() != null) {\n            throw new IllegalArgumentException(\"Fragment component present\");\n        }\n    }\n\n    @Override\n    public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException {\n        checkUri(uri);\n        throw new FileSystemAlreadyExistsException();\n    }\n\n    @Override\n    public FileSystem getFileSystem(URI uri) {\n        checkUri(uri);\n        return theFileSystem;\n    }\n","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/TruffleFileSystemProvider.java#L76-L112","documentation":"Thrown by TruffleFileSystemProvider.checkUri when the URI contains a query component (uri.getRawQuery() != null). The Truffle file system URI is strictly 'scheme:/' with no authority, query, or fragment; a query string such as 'truffle:/?key=value' is rejected. This mirrors the validation style of the JDK's built-in providers.","triggerScenarios":"Passing a URI like URI.create(\"truffle:/?readonly=true\") to newFileSystem/getFileSystem/getPath, often copied from patterns where env-style options are encoded in the query string.","commonSituations":"Porting code that targets zipfs (where env options occasionally get stuffed into URIs) or hand-building URIs with URLEncoder for configuration parameters.","solutions":["Remove the query string and use exactly URI.create(\"truffle:/\")","Pass configuration through the env Map parameter of newFileSystem, not the URI","Sanitize user-supplied URI strings before handing them to the provider"],"exampleFix":"// before\nURI uri = URI.create(\"truffle:/?mode=ro\");\nFileSystem fs = FileSystems.getFileSystem(uri);\n\n// after\nURI uri = URI.create(\"truffle:/\");\nFileSystem fs = FileSystems.getFileSystem(uri);","handlingStrategy":"validation","validationCode":"if (uri.getRawQuery() != null) { /* strip or reject before calling the provider */\n    throw new IllegalArgumentException(\"query not allowed in Truffle FS URI\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass configuration via the env Map, never the URI query","Log the exact URI at FS-acquisition time to catch malformed values early"],"tags":["espresso","nio","uri","filesystem","truffle"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}