{"record":{"id":"fa6886f2385bbaa0","repo":"risingwavelabs/risingwave","slug":"could-not-convert-url-to-file-path","errorCode":null,"errorMessage":"could not convert url {} to file path","messagePattern":"could not convert url (.+?) to file path","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/codec/src/decoder/json/mod.rs","lineNumber":141,"sourceCode":"            let ref_url = base_url.join(ref_string).into_url_parse(ref_string)?;\n            let mut ref_url_no_fragment = ref_url.clone();\n            ref_url_no_fragment.set_fragment(None);\n            let url_schema = ref_url_no_fragment.scheme();\n            let ref_no_fragment = ref_url_no_fragment.to_string();\n\n            let mut schema = match self.schema_cache.get(&ref_no_fragment) {\n                Some(cached_schema) => cached_schema.clone(),\n                None => {\n                    if url_schema == \"http\" || url_schema == \"https\" {\n                        reqwest::get(ref_url_no_fragment.clone())\n                            .await\n                            .into_request(&ref_no_fragment)?\n                            .json()\n                            .await\n                            .into_request(&ref_no_fragment)?\n                    } else if url_schema == \"file\" {\n                        let file_path = ref_url_no_fragment.to_file_path().map_err(|_| {\n                            anyhow::anyhow!(\n                                \"could not convert url {} to file path\",\n                                ref_url_no_fragment\n                            )\n                        })?;\n                        let file =\n                            fs::File::open(file_path).into_schema_from_file(&ref_no_fragment)?;\n                        serde_json::from_reader(file)\n                            .into_schema_not_json_serde(ref_no_fragment.clone())?\n                    } else {\n                        return Err(Error::UnsupportedUrl {\n                            url: ref_no_fragment,\n                        });\n                    }\n                }\n            };\n\n            if !self.schema_cache.contains_key(&ref_no_fragment) {\n                self.schema_cache","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/codec/src/decoder/json/mod.rs#L123-L159","documentation":"During `$ref` dereferencing in JsonRef::deref (src/connector/codec/src/decoder/json/mod.rs:140), a ref whose scheme is `file` is converted with Url::to_file_path(). If the file URL cannot be mapped to a platform file path, an anyhow error `could not convert url {url} to file path` is returned. This happens when Url::to_file_path is called on a URL that is syntactically a file URL but not convertible (e.g. a relative path that was never made absolute, or a Windows-style path without a host understood on Unix).","triggerScenarios":"JsonRef::deref resolves a `$ref` whose base_url joined with the ref string yields a `file` scheme URL on which `Url::to_file_path()` fails — typically a relative file URL like `file:relative/path.json` (no leading slash / no authority) rather than `file:///abs/path.json`.","commonSituations":"Using a relative `$ref` like `common.json` with a retrieval_url that itself is a `file:relative/...` style URL; supplying a Windows path `file://C:/schemas/x.json` on a Linux node; missing a slash in a `file://` URL.","solutions":["Use an absolute file URL with three slashes: `file:///absolute/path/schema.json`","If running on Linux, convert Windows-style file URLs to POSIX absolute paths","Inline the referenced schema to avoid file resolution entirely","Verify with `Url::parse(...).to_file_path()` locally that the URL converts before using it in RisingWave"],"exampleFix":"// before\n{\"$ref\": \"file://schemas/order.json\"}\n// after\n{\"$ref\": \"file:///etc/risingwave/schemas/order.json\"}","handlingStrategy":"validation","validationCode":"use url::Url;\nfn file_url_to_path(ref_url: &Url) -> Option<std::path::PathBuf> {\n    if ref_url.scheme() != \"file\" { return None; }\n    ref_url.to_file_path().ok()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use absolute file URLs with three leading slashes (file:///abs/path.json)","Never use relative file:// URLs or Windows drive letters on Linux nodes","Test Url::to_file_path conversion locally before deploying the schema"],"tags":["url","file-path","schema-ref"],"backgroundTag":"invalid-url","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}