{"record":{"id":"b55a2b8db0400ce6","repo":"oracle/graal","slug":"uri-does-not-match-this-provider","errorCode":null,"errorMessage":"URI does not match this provider","messagePattern":"URI does not match this provider","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/TruffleFileSystemProvider.java","lineNumber":81,"sourceCode":"\n    static final String SEPARATOR = getSeparator0();\n\n    TruffleFileSystemProvider() {\n        this.theFileSystem = new TruffleFileSystem(this);\n    }\n\n    TruffleFileSystem theFileSystem() {\n        return theFileSystem;\n    }\n\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    }","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso.io/src/sun/nio/fs/TruffleFileSystemProvider.java#L63-L99","documentation":"TruffleFileSystemProvider.checkUri validates URIs passed to newFileSystem/getFileSystem: the scheme must equal the provider's scheme (case-insensitive). A mismatch throws IllegalArgumentException('URI does not match this provider'), mirroring java.nio.file.FileSystemProvider contract checks.","triggerScenarios":"Calling FileSystems.newFileSystem(uri, env) or provider.newFileSystem(uri, env) with a URI whose scheme is not the Truffle scheme (e.g. 'jar:', 'file:', custom scheme) while routing to this provider, or manually invoking the provider from ServiceLoader iteration.","commonSituations":"Code iterating installed providers and calling each with an arbitrary URI; copy-pasted URI construction with the wrong scheme; URI scheme case differences are tolerated but wrong schemes are not.","solutions":["Check provider.getScheme().equalsIgnoreCase(uri.getScheme()) before calling the provider.","Use FileSystems.newFileSystem(uri, env), which routes by scheme automatically.","Construct the URI with the correct provider scheme constant."],"exampleFix":"// before\nTruffleFileSystemProvider p = ...;\np.newFileSystem(URI.create(\"file:///data\"), Map.of()); // wrong scheme -> throws\n\n// after\nif (p.getScheme().equalsIgnoreCase(uri.getScheme())) {\n    p.newFileSystem(uri, Map.of());\n}","handlingStrategy":"validation","validationCode":"if (provider.getScheme().equalsIgnoreCase(uri.getScheme())) {\n    provider.newFileSystem(uri, env);\n} else {\n    // route to the correct provider or use FileSystems.newFileSystem(uri, env)\n}","typeGuard":null,"tryCatchPattern":"try {\n    provider.newFileSystem(uri, env);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"URI does not match this provider\")) { /* wrong provider; skip */ }\n}","preventionTips":["Let FileSystems.newFileSystem route by scheme instead of manual provider iteration.","Compare getScheme() case-insensitively before calling a provider directly."],"tags":["espresso","nio","uri","filesystem-provider"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}