{"record":{"id":"b304c1c7a9f7af41","repo":"BigPizzaV3/CodexPlusPlus","slug":"config-toml-toml-parse-failed-error","errorCode":null,"errorMessage":"config.toml TOML parse failed: {error}","messagePattern":"config\\.toml TOML parse failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/plugin_marketplace.rs","lineNumber":732,"sourceCode":"}\n\nfn windows_extended_path(path: &Path) -> String {\n    let value = path.to_string_lossy();\n    if value.starts_with(r\"\\\\?\\\") {\n        value.into_owned()\n    } else {\n        format!(r\"\\\\?\\{value}\")\n    }\n}\n\nfn parse_toml_document(contents: &str) -> anyhow::Result<DocumentMut> {\n    let contents = contents.trim_start_matches('\\u{feff}');\n    if contents.trim().is_empty() {\n        Ok(DocumentMut::new())\n    } else {\n        contents\n            .parse::<DocumentMut>()\n            .map_err(|error| anyhow::anyhow!(\"config.toml TOML parse failed: {error}\"))\n    }\n}\n\nfn table_mut_or_insert<'a>(doc: &'a mut DocumentMut, key: &str) -> anyhow::Result<&'a mut Table> {\n    if !doc.as_table().contains_key(key) {\n        doc[key] = toml_edit::table();\n    }\n    if doc.get(key).and_then(Item::as_table).is_none() {\n        doc[key] = toml_edit::table();\n    }\n    doc.get_mut(key)\n        .and_then(Item::as_table_mut)\n        .ok_or_else(|| anyhow::anyhow!(\"{key} must be a TOML table\"))\n}\n\nfn ensure_trailing_newline(mut contents: String) -> String {\n    if !contents.ends_with('\\n') {\n        contents.push('\\n');","sourceCodeStart":714,"sourceCodeEnd":750,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/1f431ae49b57b3055e0e6845ba6156c6b4232b4d/crates/codex-plus-core/src/plugin_marketplace.rs#L714-L750","documentation":"Thrown by parse_toml_document in crates/codex-plus-core/src/plugin_marketplace.rs when the config.toml text it is asked to edit cannot be parsed by toml_edit. The function is tolerant of a leading UTF-8 BOM (stripped via trim_start_matches('\\u{feff}')) and of empty/whitespace-only files (those yield a fresh empty document), so this error means genuine TOML syntax errors: unclosed strings or tables, duplicate keys, or malformed inline values. The {error} placeholder carries toml_edit's message, which includes the line/column of the offending token.","triggerScenarios":"Calling the marketplace/config writer on a hand-edited ~/.codex/config.toml that contains a syntax error (e.g. an unterminated string, a duplicate [profiles.x] header, or a bare value like key = no-quotes); feeding config.toml content that was mangled by a merge conflict; a file truncated mid-write by a crash.","commonSituations":"Users hand-editing config.toml and introducing typos; git merge conflict markers (<<<<<<<) left in the file; third-party tools rewriting config.toml in a non-TOML-conformant way; CRLF or smart-quote characters pasted from rich-text editors.","solutions":["Read the {error} suffix: toml_edit reports the exact line and column — open config.toml and fix the syntax at that position","Validate the file externally before retrying, e.g. cargo toml2json or python -c \"import tomllib;tomllib.load(open('config.toml','rb'))\" to confirm it parses","Remove merge-conflict markers and duplicate table/key definitions, and quote any value containing special characters","If the file is unrecoverable, restore from the backup the tool writes next to it (or regenerate the file) instead of editing the broken one"],"exampleFix":"# before (config.toml, broken TOML)\nmodel = gpt-5  # unquoted value with a dash\n[profiles.x\nkey = \"unterminated\n\n# after\nmodel = \"gpt-5\"\n[profiles.x]\nkey = \"terminated\"","handlingStrategy":"validation","validationCode":"fn config_toml_parses(path: &Path) -> bool {\n    let text = std::fs::read_to_string(path)\n        .unwrap_or_default()\n        .trim_start_matches('\\u{feff}')\n        .to_string();\n    text.trim().is_empty()\n        || text.parse::<toml_edit::DocumentMut>().is_ok()\n}","typeGuard":null,"tryCatchPattern":"let doc = parse_toml_document(&contents)\n    .with_context(|| format!(\"config.toml is invalid — fix the syntax at the reported line, or restore {}\", path.display()))?;","preventionTips":["Run a TOML linter on config.toml after every manual edit","Resolve git merge conflicts in config.toml completely before launching the app","Quote all string values and avoid duplicate table headers"],"tags":["toml","config-parsing","toml-edit","user-config"],"backgroundTag":"toml-parse-error","analyzedSha":"1f431ae49b57b3055e0e6845ba6156c6b4232b4d","analyzedAt":"2026-08-16T20:54:18.598Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}