{"record":{"id":"0915de69a6a60195","repo":"warpdotdev/warp","slug":"failed-to-parse-codex-toml-e","errorCode":null,"errorMessage":"Failed to parse Codex TOML: {e}","messagePattern":"Failed to parse Codex TOML: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"app/src/ai/mcp/parsing.rs","lineNumber":159,"sourceCode":"\n                JSONTransportType::SSEServer {\n                    url,\n                    headers: merged_headers,\n                }\n            }\n        }\n    }\n}\n\n/// Normalizes the contents of a Codex `config.toml` into a JSON string\n/// compatible with `ParsedTemplatableMCPServerResult::from_user_json`.\n#[cfg(feature = \"local_fs\")]\npub(crate) fn normalize_codex_toml_to_json(file_contents: &str) -> Result<String, anyhow::Error> {\n    // Parse into a raw Value first so we can handle per-entry deserialization failures\n    // gracefully. Using HashMap<String, CodexServerEntry> directly would cause the entire\n    // parse to fail if any single entry matches neither Stdio nor Http.\n    let raw: toml::Value = toml::from_str(file_contents)\n        .map_err(|e| anyhow::anyhow!(\"Failed to parse Codex TOML: {e}\"))?;\n\n    let out_servers: HashMap<String, JSONMCPServer> = raw\n        .get(\"mcp_servers\")\n        .and_then(|v| v.as_table())\n        .map(|table| {\n            table\n                .iter()\n                .filter_map(|(name, val)| {\n                    val.clone()\n                        .try_into::<CodexServerEntry>()\n                        .ok()\n                        .map(|entry| {\n                            (\n                                name.clone(),\n                                JSONMCPServer {\n                                    transport_type: JSONTransportType::from(entry),\n                                },\n                            )","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/mcp/parsing.rs#L141-L177","documentation":"`normalize_codex_toml_to_json` (feature `local_fs`) parses a Codex `config.toml` with `toml::from_str::<toml::Value>` before normalizing `mcp_servers` entries into JSON. This error means the file is not valid TOML syntax at all — it fires at the whole-file parse. Per-entry type mismatches (an entry matching neither Stdio nor Http) are intentionally tolerated later via `filter_map(... .ok())` and do NOT produce this error.","triggerScenarios":"The Codex config file has a TOML syntax error: unclosed table or string, duplicate keys, missing `=` or quotes, malformed arrays/indentation, a BOM, or a truncated file read mid-write by the file watcher.","commonSituations":"Hand-editing config.toml and leaving a syntax mistake; pasting JSON (not TOML) into config.toml; two tools writing the file concurrently so the watcher reads a half-written file; tabs breaking multiline arrays.","solutions":["Validate the file with a TOML linter/editor with TOML LSP — the wrapped {e} includes the line/column of the syntax error","Fix common TOML mistakes: quote string values, use [mcp_servers.name] tables, close all brackets and strings","Restore from backup or re-create the file if it was truncated by a concurrent write","Write config files atomically (temp file + rename) so watchers never observe partial content"],"exampleFix":"# before (invalid TOML: unquoted command, stray trailing token)\n[mcp_servers.fetch]\ncommand = npx\nargs = [-y, fetch-mcp]  extra\n\n# after\n[mcp_servers.fetch]\ncommand = \"npx\"\nargs = [\"-y\", \"fetch-mcp\"]","handlingStrategy":"validation","validationCode":"// Validate TOML before normalizing; surface the span to the user instead of failing late.\nif let Err(e) = toml::from_str::<toml::Value>(&file_contents) {\n    let offset = e.span().map(|s| s.start).unwrap_or(0);\n    return Err(anyhow!(\"config.toml is invalid TOML near offset {offset}: {e}\"));\n}","typeGuard":"fn is_valid_toml(contents: &str) -> bool {\n    toml::from_str::<toml::Value>(contents).is_ok()\n}","tryCatchPattern":"match normalize_codex_toml_to_json(&file_contents) {\n    Ok(json) => json,\n    Err(e) if e.to_string().contains(\"Failed to parse Codex TOML\") => {\n        // surface as a per-file config diagnostic and skip this provider\n        diagnostics.push(FileMCPConfigDiagnostic { kind: Parse, message: e.to_string(), .. });\n        continue;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Edit TOML with an editor that has TOML language support / LSP","Write config files atomically (temp file + rename) so watchers never read partial files","Keep a known-good backup of config.toml before hand-editing"],"tags":["mcp","toml","config","parsing","codex"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}