{"record":{"id":"9932b61f8f914ff6","repo":"linera-io/linera-protocol","slug":"could-not-parse-os-string-into-string","errorCode":null,"errorMessage":"could not parse OS string into string: {}","messagePattern":"could not parse OS string into string: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-service/src/cli_wrappers/local_net.rs","lineNumber":698,"sourceCode":"                    let host = exporter.host.clone();\n                    let port = exporter.port;\n                    let config_content = format!(\n                        r#\"\n\n                        [[block_exporters]]\n                        host = \"{host}\"\n                        port = {port}\n                        \"#\n                    );\n\n                    content.push_str(&config_content);\n                }\n            }\n        }\n\n        fs_err::write(&path, content)?;\n        path.into_os_string().into_string().map_err(|error| {\n            anyhow!(\n                \"could not parse OS string into string: {}\",\n                error.to_string_lossy()\n            )\n        })\n    }\n\n    fn generate_block_exporter_config(\n        &self,\n        validator: usize,\n        exporter_id: u32,\n        destination_config: &DestinationConfig,\n    ) -> String {\n        let n = validator;\n        let host = Network::Grpc.localhost();\n        let port = self.block_exporter_port(n, exporter_id as usize);\n        let metrics_port = Self::block_exporter_metrics_port(exporter_id as usize);\n        let mut config = format!(\n            r#\"","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-service/src/cli_wrappers/local_net.rs#L680-L716","documentation":"A filesystem path that must be returned as a String contains bytes that are not valid UTF-8. On Unix, paths are arbitrary byte strings; OsString::into_string() enforces UTF-8, so a temp dir or parent directory with non-UTF-8 bytes (odd locale filenames, corrupted names) makes the test-net config writer fail.","triggerScenarios":"local_net's configuration_string writes the validator config to a path derived from the temp/config directory, then converts it via into_string(); TMPDIR, CARGO_TARGET_TMPDIR, or the repo path containing non-UTF-8 bytes triggers the error.","commonSituations":"CI images or mount points with legacy-encoding directory names; a TMPDIR set from a misconfigured shell; filenames mangled during archive extraction across systems.","solutions":["Set TMPDIR (and CARGO_TARGET_TMPDIR for Rust test tempdirs) to a clean UTF-8 path.","Run the test suite from a checkout whose full path is valid UTF-8.","Rename the offending directory.","In library code, avoid the conversion: return/keep PathBuf, or use to_str() with an actionable error."],"exampleFix":"// before: hard failure on non-UTF-8 path bytes\npath.into_os_string().into_string().map_err(|error| {\n    anyhow!(\"could not parse OS string into string: {}\", error.to_string_lossy())\n})?\n\n// after: keep the PathBuf — no UTF-8 requirement is actually needed\nOk(path) // callers use it as a path, not as a String","handlingStrategy":"validation","validationCode":"if path.to_str().is_none() {\n    anyhow::bail!(\n        \"path {:#?} is not valid UTF-8 — set TMPDIR to a UTF-8 directory\",\n        path.display()\n    );\n}","typeGuard":"fn is_utf8_path(p: &std::path::Path) -> bool {\n    p.to_str().is_some()\n}","tryCatchPattern":null,"preventionTips":["Set TMPDIR/CARGO_TARGET_TMPDIR to clean UTF-8 paths in CI and dev shells.","Prefer returning PathBuf over String for file paths in library APIs.","Check checkout paths after extracting archives from other platforms."],"tags":["path","utf8","testing","config"],"backgroundTag":"non-utf8-path","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}