{"record":{"id":"a44b5b863bbe1c9e","repo":"BoundaryML/baml","slug":"parse-error-e","errorCode":null,"errorMessage":"Parse error: {e}","messagePattern":"Parse error: (.+?)","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"baml_language/crates/tools_stow/src/main.rs","lineNumber":540,"sourceCode":"        let folder_name = crate_dir.file_name()?.to_string_lossy().into_owned();\n\n        let content = std::fs::read_to_string(&cargo_path).ok()?;\n        let doc: DocumentMut = content.parse().ok()?;\n        let crate_name = extract_crate_name(&doc, &folder_name).to_owned();\n\n        Some(CrateInfo {\n            cargo_path,\n            folder_name,\n            crate_name,\n            doc,\n        })\n    }\n\n    /// Reload the document from disk (after fixes).\n    fn reload(&mut self) -> std::io::Result<()> {\n        let content = std::fs::read_to_string(&self.cargo_path)?;\n        self.doc = content.parse().map_err(|e| {\n            std::io::Error::new(std::io::ErrorKind::InvalidData, format!(\"Parse error: {e}\"))\n        })?;\n        self.crate_name = extract_crate_name(&self.doc, &self.folder_name).to_owned();\n        Ok(())\n    }\n}\n\nstruct ManifestSelection {\n    root_dir: PathBuf,\n    manifest_path: PathBuf,\n    is_workspace: bool,\n}\n\nfn find_best_manifest() -> Option<ManifestSelection> {\n    let mut dir = std::env::current_dir().ok()?;\n    let mut fallback_manifest: Option<PathBuf> = None;\n\n    loop {\n        let cargo_toml = dir.join(\"Cargo.toml\");","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/tools_stow/src/main.rs#L522-L558","documentation":"The stow tool reloads a Cargo.toml document from disk after applying fixes and parses it with toml_edit. If parsing fails, the toml error is wrapped into an std::io::Error of kind InvalidData with the message \"Parse error: {e}\". This means the file on disk is not valid TOML (or has constructs toml_edit rejects) at reload time.","triggerScenarios":"reload() reads self.cargo_path and calls content.parse::<DocumentMut>(); any toml_edit parse failure — after the tool wrote edits or another process modified the file — triggers this error.","commonSituations":"A previous partially-failed write left truncated TOML; manual edits during the run introduced syntax errors; duplicate keys introduced by concurrent tooling; leftover merge-conflict markers in the manifest.","solutions":["Open the Cargo.toml at the reported path and fix the TOML syntax error cited by the inner message.","Restore the file from git (git checkout -- Cargo.toml) if a stow write corrupted it.","Re-run the stow command after fixing so the reload succeeds.","Check for concurrent processes editing the same manifest and retry after they finish."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let content = std::fs::read_to_string(\"Cargo.toml\")?;\\ntoml::from_str::<toml::Value>(&content).expect(\"Cargo.toml is not valid TOML before running stow\");","typeGuard":null,"tryCatchPattern":"match result {\\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidData && e.to_string().starts_with(\"Parse error\") => {\\n        eprintln!(\"{cargo_path} is invalid TOML: {e}; restore from git\");\\n    }\\n    other => other?,\\n}","preventionTips":["Run `cargo check` (which parses manifests) before stow passes.","Avoid manual edits to manifests while tooling runs.","Restore manifests with `git checkout -- Cargo.toml` after failed runs.","Keep files BOM-free UTF-8."],"tags":["toml","parsing","rust"],"backgroundTag":"toml-parse-error","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}