{"record":{"id":"ebf4a2f1863a4af6","repo":"openai/codex","slug":"invaliddata-ebf4a2","errorCode":"InvalidData","errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/config/src/marketplace_edit.rs","lineNumber":52,"sourceCode":"    upsert_marketplace(&mut doc, marketplace_name, update);\n    fs::create_dir_all(codex_home)?;\n    fs::write(config_path, doc.to_string())\n}\n\npub fn remove_user_marketplace(codex_home: &Path, marketplace_name: &str) -> std::io::Result<bool> {\n    let outcome = remove_user_marketplace_config(codex_home, marketplace_name)?;\n    Ok(outcome == RemoveMarketplaceConfigOutcome::Removed)\n}\n\npub fn remove_user_marketplace_config(\n    codex_home: &Path,\n    marketplace_name: &str,\n) -> std::io::Result<RemoveMarketplaceConfigOutcome> {\n    let config_path = codex_home.join(CONFIG_TOML_FILE);\n    let mut doc = match fs::read_to_string(&config_path) {\n        Ok(raw) => raw\n            .parse::<DocumentMut>()\n            .map_err(|err| std::io::Error::new(ErrorKind::InvalidData, err))?,\n        Err(err) if err.kind() == ErrorKind::NotFound => {\n            return Ok(RemoveMarketplaceConfigOutcome::NotFound);\n        }\n        Err(err) => return Err(err),\n    };\n\n    let outcome = remove_marketplace(&mut doc, marketplace_name);\n    if outcome != RemoveMarketplaceConfigOutcome::Removed {\n        return Ok(outcome);\n    }\n\n    fs::create_dir_all(codex_home)?;\n    fs::write(config_path, doc.to_string())?;\n    Ok(RemoveMarketplaceConfigOutcome::Removed)\n}\n\nfn read_or_create_document(config_path: &Path) -> std::io::Result<DocumentMut> {\n    match fs::read_to_string(config_path) {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/config/src/marketplace_edit.rs#L34-L70","documentation":"remove_user_marketplace_config edits $CODEX_HOME/config.toml through toml_edit so comments and formatting survive the write. Before removing a [marketplaces] entry it parses the whole document; if the file is not valid TOML, the toml_edit::TomlError is wrapped as io::Error(InvalidData) with its message, and the removal aborts rather than rewriting a file the editor cannot faithfully round-trip. A missing file is not an error (it returns the NotFound outcome).","triggerScenarios":"Calling remove_user_marketplace or remove_user_marketplace_config while config.toml contains any TOML syntax error — unquoted value, duplicate key, unterminated table or string, or a stray comma in an inline table like `marketplaces = { debug = {...}, }`.","commonSituations":"Hand-edited config.toml with a typo; leftover git merge-conflict markers; files assembled by concatenating snippets; smart quotes pasted from docs or chat; a truncated file after a previously crashed writer.","solutions":["Open config.toml at the line/column named in the error message and fix the syntax error (unquoted strings and duplicate keys are the usual suspects)","Round-trip check before retrying: python3 -c \"import tomllib;tomllib.load(open('config.toml','rb'))\" or taplo lint","If the file is unrecoverable, back it up and delete it — removal then returns NotFound instead of an error"],"exampleFix":"# before ($CODEX_HOME/config.toml) — unquoted value\n[marketplaces.debug]\nsource_type = git\nsource = \"https://github.com/owner/repo.git\"\n\n# after\n[marketplaces.debug]\nsource_type = \"git\"\nsource = \"https://github.com/owner/repo.git\"","handlingStrategy":"validation","validationCode":"use std::fs;\nuse std::io;\nuse std::path::Path;\nuse toml_edit::DocumentMut;\n\n// Run before remove_user_marketplace_config so edits never start from a broken file.\nfn config_toml_parses(codex_home: &Path) -> io::Result<()> {\n    let raw = fs::read_to_string(codex_home.join(\"config.toml\"))?;\n    raw.parse::<DocumentMut>()\n        .map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))?;\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match remove_user_marketplace_config(codex_home, name) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidData => {\n        // e's message embeds the toml_edit parse error with line/column;\n        // surface it and have the user fix config.toml before retrying.\n    }\n    Err(e) => return Err(e),\n    Ok(outcome) => match outcome {\n        RemoveMarketplaceConfigOutcome::Removed => {}\n        RemoveMarketplaceConfigOutcome::NotFound => {}\n        RemoveMarketplaceConfigOutcome::NameCaseMismatch { configured_name } => {}\n    },\n}","preventionTips":["Validate config.toml (taplo lint / python tomllib) after every manual edit","Let codex CLI commands edit marketplaces so writes round-trip through toml_edit instead of hand edits","Never leave merge-conflict markers or duplicate keys in config.toml"],"tags":["toml","config","marketplace","parse-error","rust"],"backgroundTag":"toml-parse-error","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}