{"record":{"id":"62924b14c417a3c4","repo":"oracle/graal","slug":"path-component-should-be","errorCode":null,"errorMessage":"Path component should be '/'","messagePattern":"Path component should be '/'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/TruffleFileSystemProvider.java","lineNumber":91,"sourceCode":"\n    @Override\n    public String getScheme() {\n        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);","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/TruffleFileSystemProvider.java#L73-L109","documentation":"Thrown by TruffleFileSystemProvider.checkUri when the URI's path component is defined but is not exactly '/'. The provider models a single root-only file system, so the URI must identify the root and nothing else; any deeper or empty-but-non-root path is rejected. Paths below the root are created via getPath, never via the URI.","triggerScenarios":"Calling newFileSystem/getFileSystem/getPath with URIs such as URI.create(\"truffle:/data\"), URI.create(\"truffle://host/\") (authority also rejected), or URI.create(\"truffle:\") which yields an empty path \"\".","commonSituations":"Assuming the Truffle provider works like jar/zip providers where the URI carries the archive path, or trying to select a subdirectory by embedding it in the filesystem URI.","solutions":["Use exactly URI.create(\"truffle:/\") when addressing the file system","Obtain sub-paths with fs.getPath(\"data\", \"file.txt\") after acquiring the FileSystem, not via the URI","Prefer FileSystems.getFileSystem(...) over newFileSystem since the root FS already exists (newFileSystem throws FileSystemAlreadyExistsException)"],"exampleFix":"// before\nFileSystem fs = FileSystems.newFileSystem(URI.create(\"truffle:/data\"), Map.of());\n\n// after\nFileSystem fs = FileSystems.getFileSystem(URI.create(\"truffle:/\"));\nPath data = fs.getPath(\"data\", \"file.txt\");","handlingStrategy":"validation","validationCode":"if (!\"/\".equals(uri.getPath())) {\n    throw new IllegalArgumentException(\"Truffle FS URI path must be '/', got: \" + uri.getPath());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the Truffle FS URI as an opaque constant, not a template","Derive sub-paths only via FileSystem.getPath(...)"],"tags":["espresso","nio","uri","filesystem","truffle"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}