{"record":{"id":"e9d038af603d592d","repo":"xai-org/grok-build","slug":"claude-compat-is-not-a-table","errorCode":null,"errorMessage":"[claude_compat] is not a table","messagePattern":"\\[claude_compat\\] is not a table","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shell/src/claude_import.rs","lineNumber":635,"sourceCode":"                \"refusing to write import marker: existing config at {} is \\\n                 not valid TOML ({}). Fix the file (or move it aside) and \\\n                 retry.\",\n                config_path.display(),\n                e\n            )\n        })?,\n        Err(e) if e.kind() == std::io::ErrorKind::NotFound => TomlValue::Table(TomlMap::new()),\n        Err(e) => return Err(e.into()),\n    };\n    let table = root\n        .as_table_mut()\n        .ok_or_else(|| anyhow::anyhow!(\"config root is not a table\"))?;\n    let compat = table\n        .entry(\"claude_compat\")\n        .or_insert_with(|| TomlValue::Table(TomlMap::new()));\n    let compat_table = compat\n        .as_table_mut()\n        .ok_or_else(|| anyhow::anyhow!(\"[claude_compat] is not a table\"))?;\n    compat_table.insert(\"imported\".to_string(), TomlValue::Boolean(true));\n\n    let toml_str = toml::to_string_pretty(&root)?;\n    if let Some(parent) = config_path.parent() {\n        std::fs::create_dir_all(parent)?;\n    }\n    let tmp = config_path.with_extension(\"toml.tmp\");\n    // Best-effort cleanup of the .tmp file if either write or rename fails so\n    // a failed marker write doesn't leave a stale artefact next to the real\n    // config (otherwise the next attempt would inherit a half-written file\n    // before the rename clobbers it).\n    if let Err(e) = std::fs::write(&tmp, &toml_str) {\n        let _ = std::fs::remove_file(&tmp);\n        return Err(e.into());\n    }\n    if let Err(e) = std::fs::rename(&tmp, config_path) {\n        let _ = std::fs::remove_file(&tmp);\n        return Err(e.into());","sourceCodeStart":617,"sourceCodeEnd":653,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shell/src/claude_import.rs#L617-L653","documentation":"write_import_marker found a key named claude_compat in the config whose value is not a table, so an imported marker cannot be inserted into it. The code only creates a table when the key is missing; a non-table existing value triggers this error.","triggerScenarios":"The config contains e.g. claude_compat = true or claude_compat = \"x\" at the root, then mark_claude_imported/write_import_marker runs.","commonSituations":"A user manually added claude_compat as a boolean or string instead of a [claude_compat] section; a prior tool wrote the key in scalar form.","solutions":["Edit the config to replace the scalar claude_compat value with a proper [claude_compat] section.","Remove the offending key entirely and re-run the import so it creates the table.","Set claude_compat = { imported = false } as an inline table before importing."],"exampleFix":"// before (config.toml)\nclaude_compat = true\n\n// after\n[claude_compat]\nimported = true","handlingStrategy":"validation","validationCode":"let root: toml::Value = toml::from_str(&std::fs::read_to_string(&path)?)?;\nif let Some(v) = root.get(\"claude_compat\") {\n    if !v.is_table() {\n        anyhow::bail!(\"claude_compat must be a table, got: {:?}\", v.type_name());\n    }\n}","typeGuard":"fn claude_compat_is_table(root: &toml::Value) -> bool {\n    root.get(\"claude_compat\").map(|v| v.is_table()).unwrap_or(true)\n}","tryCatchPattern":"if let Err(e) = write_import_marker(&path) {\n    if e.to_string().contains(\"[claude_compat] is not a table\") {\n        eprintln!(\"Replace scalar claude_compat key with a [claude_compat] section: {e}\");\n    } else {\n        return Err(e.into());\n    }\n}","preventionTips":["Always write claude_compat as a [claude_compat] section, never a bare scalar key.","Document the expected section shape for users editing configs by hand.","Prefer letting the import tool create the section rather than pre-creating it manually."],"tags":["toml","config","schema"],"backgroundTag":"invalid-toml-config","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}