{"record":{"id":"59313b5cddb54b41","repo":"juicedata/juicefs","slug":"bug-could-not-build-fs-uri","errorCode":null,"errorMessage":"[BUG] Could not build FS URI","messagePattern":"\\[BUG\\] Could not build FS URI","errorType":"exception","errorClass":"DatasetOperationException","httpStatus":null,"severity":"error","filePath":"sdk/java/src/main/java/io/juicefs/KiteDataLoader.java","lineNumber":75,"sourceCode":"      // load hdfs-site.xml by loading HdfsConfiguration\n      FileSystem.getLocal(DefaultConfiguration.get());\n    } catch (IOException e) {\n      throw new DatasetIOException(\"Cannot load default config\", e);\n    }\n\n    OptionBuilder<DatasetRepository> builder = new URIBuilder();\n    Registration.register(\n            new URIPattern(\"jfs:/*path\"),\n            new URIPattern(\"jfs:/*path/:namespace/:dataset\"),\n            builder);\n  }\n\n  private static URI fileSystemURI(Map<String, String> match) {\n    try {\n      return new URI(match.get(URIPattern.SCHEME), null,\n              match.get(URIPattern.HOST), -1, \"/\", null, null);\n    } catch (URISyntaxException ex) {\n      throw new DatasetOperationException(\"[BUG] Could not build FS URI\", ex);\n    }\n  }\n}\n","sourceCodeStart":57,"sourceCodeEnd":79,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/src/main/java/io/juicefs/KiteDataLoader.java#L57-L79","documentation":"fileSystemURI builds the filesystem URI from the URI match map (scheme + host) using new URI(scheme, null, host, -1, \"/\", null, null). A URISyntaxException here indicates the matched scheme/host string is not a legal URI, which the loader treats as an internal invariant bug and wraps in DatasetOperationException prefixed with [BUG].","triggerScenarios":"Calling getFromOptions with a jfs: URI whose matched scheme or host group contains characters illegal in a URI authority (spaces, brackets, control chars), producing URISyntaxException inside fileSystemURI.","commonSituations":"Hand-typing a malformed URI like 'jfs://my vol/path' or 'jfs://[weird]/x' into a Kite-based tool; a pattern upgrade changing URIPattern group capture so a path fragment lands in the HOST slot.","solutions":["Fix the input URI: remove illegal characters from scheme/host and quote or percent-encode anything unusual.","Log/inspect the URISyntaxException cause (it names the offending index and reason) and correct the URI accordingly.","If it occurs with a well-formed URI, check for a version mismatch between KiteDataLoader and the URIPattern groups (host capturing the wrong text) and pin matching versions."],"exampleFix":"// before\nDatasetRepository r = loader.getFromOptions(match); // match host = \"my vol\"\n// after\nDatasetRepository r = loader.getFromOptions(match); // uri = jfs://myvol/path (no spaces in host)","handlingStrategy":"validation","validationCode":"URI u = java.net.URI.create(uriString); // throws IllegalArgumentException on illegal chars\nif (u.getHost() == null || !u.getHost().matches(\"[A-Za-z0-9.\\\\-]+\")) {\n  throw new IllegalArgumentException(\"illegal host in URI: \" + uriString);\n}","typeGuard":null,"tryCatchPattern":"try {\n  DatasetRepository repo = loader.getFromOptions(match);\n} catch (DatasetOperationException e) {\n  throw new IllegalArgumentException(\"malformed jfs URI (host/scheme): \" + e.getCause().getMessage(), e);\n}","preventionTips":["Build URIs with URI.create or the multi-arg URI constructor rather than string concat.","Reject URIs with spaces or brackets in the authority at input validation.","Keep KiteDataLoader and URIPattern versions aligned."],"tags":["java","uri","internal-error"],"backgroundTag":"invalid-url-format","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}