{"record":{"id":"3f6ffcb45af9cdb2","repo":"xai-org/grok-build","slug":"marketplace-is-not-a-table","errorCode":null,"errorMessage":"[marketplace] is not a table","messagePattern":"\\[marketplace\\] is not a table","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shell/src/extensions/marketplace.rs","lineNumber":978,"sourceCode":"    source: &crate::plugin::MarketplaceAddInput,\n    set_official_flag: bool,\n) -> std::io::Result<()> {\n    if let Some(parent) = config_path.parent() {\n        let _ = std::fs::create_dir_all(parent);\n    }\n    let existing = crate::util::config::read_to_string_or_empty(config_path)?;\n    let mut doc = existing.parse::<toml_edit::DocumentMut>().map_err(|e| {\n        std::io::Error::new(\n            std::io::ErrorKind::InvalidData,\n            format!(\"invalid TOML: {e}\"),\n        )\n    })?;\n\n    let marketplace_item = doc\n        .entry(\"marketplace\")\n        .or_insert_with(|| toml_edit::Item::Table(toml_edit::Table::new()));\n    let marketplace = marketplace_item.as_table_mut().ok_or_else(|| {\n        std::io::Error::new(\n            std::io::ErrorKind::InvalidData,\n            \"[marketplace] is not a table\",\n        )\n    })?;\n\n    let sources_item = marketplace\n        .entry(\"sources\")\n        .or_insert_with(|| toml_edit::Item::ArrayOfTables(toml_edit::ArrayOfTables::new()));\n    let sources = sources_item.as_array_of_tables_mut().ok_or_else(|| {\n        std::io::Error::new(\n            std::io::ErrorKind::InvalidData,\n            \"[[marketplace.sources]] is not an array of tables\",\n        )\n    })?;\n\n    // Skip if the normalized URL / path already exists: the pre-lock dup check\n    // in handle_add_source can let two serialized adds reach here.\n    use crate::plugin::MarketplaceAddInput;","sourceCodeStart":960,"sourceCodeEnd":996,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shell/src/extensions/marketplace.rs#L960-L996","documentation":"add_marketplace_source inserts-or-fetches the `marketplace` key and calls as_table_mut; if that entry exists but is not a TOML table (e.g. it's a string, integer, or array), the write aborts with ErrorKind::InvalidData and message \"[marketplace] is not a table\" (marketplace.rs:977-982). The code cannot attach [[marketplace.sources]] to a non-table value.","triggerScenarios":"config.toml already defines `marketplace` as a scalar or array (e.g. `marketplace = \"x\"` or `marketplace = [1]`) when add_marketplace_source runs.","commonSituations":"Hand-edited config using the wrong shape for the marketplace key; older config format where `marketplace` was a plain value; copy-paste from docs of a different tool.","solutions":["Open config.toml and change the `marketplace` entry to a table: `[marketplace]` (remove the scalar/array assignment).","Migrate old-format settings into the table form, e.g. move values under [marketplace] and sources under [[marketplace.sources]].","Back up the file first so the migration can be reverted if other tooling depended on the old shape."],"exampleFix":"// before: wrong shape\nmarketplace = \"official\"\n// after: table shape expected by the tool\n[marketplace]\n[[marketplace.sources]]\nname = \"official\"\nurl = \"https://github.com/example/marketplace\"","handlingStrategy":"validation","validationCode":"// ensure `marketplace` is a table before appending sources\nlet doc = raw.parse::<toml_edit::DocumentMut>()?;\nif let Some(item) = doc.get(\"marketplace\") {\n    if item.as_table().is_none() && !item.is_none() {\n        eprintln!(\"config: `marketplace` must be a table, found another type\");\n    }\n}","typeGuard":"fn marketplace_is_table(doc: &toml_edit::DocumentMut) -> bool {\n    doc.get(\"marketplace\").map_or(true, |i| i.as_table().is_some())\n}","tryCatchPattern":"match add_marketplace_source(&cfg, name, &input, false) {\n    Err(e) if e.to_string().contains(\"[marketplace] is not a table\") => {\n        eprintln!(\"fix config: replace scalar `marketplace = ...` with a [marketplace] table\");\n    }\n    other => other,\n}","preventionTips":["Follow the documented config schema: [marketplace] table with [[marketplace.sources]] entries.","Grep config for `marketplace =` scalar assignments before running add commands.","Back up config.toml before manual restructuring."],"tags":["toml","config","marketplace","schema"],"backgroundTag":"toml-type-mismatch","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}