{"record":{"id":"c4a51118d5d8cfef","repo":"windmill-labs/windmill","slug":"failed-to-parse-cargo-toml-default","errorCode":null,"errorMessage":"Failed to parse Cargo.toml.default","messagePattern":"Failed to parse Cargo\\.toml\\.default","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"backend/parsers/windmill-parser-rust/src/lib.rs","lineNumber":183,"sourceCode":"            match dep.contains('=') {\n                true => {\n                    r.push_str(dep);\n                    r.push('\\n');\n                }\n                false => {\n                    r.push_str(dep);\n                    r.push_str(\"=\\\"*\\\"\\n\");\n                }\n            }\n        }\n\n        toml::from_str(&r)\n    }\n}\n\nfn default_manifest() -> toml::value::Table {\n    toml::from_str(include_str!(\"../manifest/Cargo.toml.default\"))\n        .expect(\"Failed to parse Cargo.toml.default\")\n}\n\n/**\n* Get a `Manifest` that can be made into a TOML table. The format and logic are the same as in\n* the rust-script or cargo-eval projects.\n*/\nfn find_embedded_manifest(s: &str) -> Option<Manifest> {\n    find_short_hand_manifest(s).or_else(|| find_code_block_manifest(s))\n}\n\nfn find_short_hand_manifest(s: &str) -> Option<Manifest> {\n    let re: Regex = Regex::new(r\"^(?i)\\s*//\\s*cargo-deps\\s*:(.*?)(\\r\\n|\\n)\").unwrap();\n    /*\n    This is pretty simple: the only valid syntax for this is for the first, non-blank line to contain a single-line comment whose first token is `cargo-deps:`.  That's it.\n    */\n    if let Some(cap) = re.captures(s) {\n        if let Some(m) = cap.get(1) {\n            return Some(Manifest::DepList(m.as_str().to_string()));","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-rust/src/lib.rs#L165-L201","documentation":"default_manifest loads the vendored manifest/Cargo.toml.default (embedded via include_str!) and parses it into a TOML table to build the base manifest for Rust script dependency resolution. The .expect panics if the embedded default file is not valid TOML — this indicates a broken build artifact/shipped crate rather than user input, since the file is compiled into the binary.","triggerScenarios":"parse_rust_deps_into_manifest calling default_manifest() when the bundled ../manifest/Cargo.toml.default cannot be deserialized by toml::from_str (e.g. corrupted or hand-edited manifest shipped in the crate).","commonSituations":"A modified/corrupted Cargo.toml.default in a source checkout or vendored dependency; a bad merge that left the TOML syntactically invalid; building from a partial/corrupted source tree.","solutions":["Validate the file: run `cargo metadata`-style check or any TOML linter on backend/parsers/windmill-parser-rust/manifest/Cargo.toml.default and fix syntax errors.","Restore the file with `git checkout -- backend/parsers/windmill-parser-rust/manifest/Cargo.toml.default`.","Rebuild cleanly (cargo clean) if a stale build artifact is suspected.","In code, replace expect with a descriptive anyhow error if you want a non-panicking path."],"exampleFix":"// before\ntoml::from_str(include_str!(\"../manifest/Cargo.toml.default\"))\n    .expect(\"Failed to parse Cargo.toml.default\")\n// after\ntoml::from_str(include_str!(\"../manifest/Cargo.toml.default\"))\n    .map_err(|e| anyhow!(\"Failed to parse Cargo.toml.default: {e}\"))?","handlingStrategy":"validation","validationCode":"// Validate the embedded default manifest is well-formed TOML at build/startup time\nlet raw = include_str!(\"../manifest/Cargo.toml.default\");\nlet _table: toml::value::Table = toml::from_str(raw)\n    .expect(\"bundled Cargo.toml.default is not valid TOML; restore the file\");","typeGuard":null,"tryCatchPattern":"// The call panics via expect; isolate if a broken artifact must not take the process down:\nlet manifest = std::panic::catch_unwind(default_manifest)\n    .map_err(|_| anyhow!(\"Failed to parse Cargo.toml.default; check the shipped manifest file\"))?;","preventionTips":["Never hand-edit manifest/Cargo.toml.default; keep it under version control","Add a unit test (test_default_manifest exists) to CI so TOML regressions fail early","Restore the file with git checkout after bad merges","Run cargo clean if build artifacts are suspected corrupted"],"tags":["rust","toml","parsing","panic","build-artifact"],"backgroundTag":"toml-parse-failed","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}