{"record":{"id":"b2402d2204604dc9","repo":"Hmbown/CodeWhale","slug":"failed-to-render-mcp-template-json-e","errorCode":null,"errorMessage":"Failed to render MCP template JSON: {e}","messagePattern":"Failed to render MCP template JSON: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"info","filePath":"crates/tui/src/lib.rs","lineNumber":3227,"sourceCode":"            connect_timeout: None,\n            execute_timeout: None,\n            read_timeout: None,\n            disabled: true,\n            enabled: true,\n            required: false,\n            enabled_tools: Vec::new(),\n            disabled_tools: Vec::new(),\n            headers: std::collections::HashMap::new(),\n            env_headers: std::collections::HashMap::new(),\n            bearer_token_env_var: None,\n            scopes: Vec::new(),\n            oauth: None,\n            oauth_resource: None,\n            reviewed_plugin: None,\n        },\n    );\n    serde_json::to_string_pretty(&cfg)\n        .map_err(|e| anyhow!(\"Failed to render MCP template JSON: {e}\"))\n}\n\nfn init_mcp_config(path: &Path, force: bool) -> Result<WriteStatus> {\n    let template = mcp_template_json()?;\n    write_template_file(path, &template, force)\n}\n\nfn skills_template(name: &str) -> String {\n    format!(\n        \"\\\n---\\n\\\nname: {name}\\n\\\ndescription: Quick repo diagnostics and setup guidance\\n\\\nallowed-tools: diagnostics, list_dir, read_file, grep_files, git_status, git_diff\\n\\\n---\\n\\n\\\nWhen this skill is active:\\n\\\n1. Run the diagnostics tool to report workspace and sandbox status.\\n\\\n2. Skim key project files (README.md, Cargo.toml, AGENTS.md) before editing.\\n\\","sourceCodeStart":3209,"sourceCodeEnd":3245,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/tui/src/lib.rs#L3209-L3245","documentation":"mcp_template_json() builds the default MCP config template and serializes it with serde_json::to_string_pretty. The template contains only strings, numbers, and string-keyed maps, so serialization cannot realistically fail; this error is a guard against a future code change that adds a non-serializable shape to the template struct.","triggerScenarios":"Only a code change can trigger it: adding a map with non-string keys, a field type without a Serialize impl, or a value serde_json rejects. Users could hit it via 'codewhale init' on a broken development build.","commonSituations":"Essentially never in released builds; seen only on dev branches after template struct edits without a matching Serialize derivation or test update.","solutions":["As a user: update to a released build — the shipped template is covered by tests","As a developer: run cargo test -p codewhale-tui --lib after editing the template struct","Keep template fields to String, numbers, Vec, and HashMap<String, _>","If you need a custom MCP config, write the JSON file directly instead of using init"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let template = mcp_template_json()\n    .context(\"MCP template generation failed; this indicates a broken build, not a config problem\")?;\nwrite_template_file(path, &template, force)","preventionTips":["Run the template serialization tests after any template struct change","Keep template fields string-keyed and Serialize-derived","Use released builds — the shipped template cannot fail to serialize"],"tags":["rust","mcp","serde","template","init"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}