{"record":{"id":"61a760ad48f3a9e1","repo":"Hmbown/CodeWhale","slug":"active-profile-is-missing-or-malformed","errorCode":null,"errorMessage":"active profile is missing or malformed","messagePattern":"active profile is missing or malformed","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/commands/groups/config/config.rs","lineNumber":2488,"sourceCode":"                        ),\n                );\n            };\n            let value = preset.as_setting();\n            let scope = if persist {\n                let saved = crate::config_persistence::config_toml_path(app.config_path.as_deref())\n                    .and_then(|path| {\n                        crate::config_persistence::mutate_config_document(&path, |doc| {\n                            // Profiles replace the whole TUI table on load. Edit its\n                            // existing owner without creating an empty override that\n                            // would reset the other inherited display settings.\n                            let mut segments = Vec::new();\n                            if let Some(profile) = app.config_profile.as_deref() {\n                                let table = doc\n                                    .get(\"profiles\")\n                                    .and_then(|v| v.get(profile))\n                                    .and_then(toml_edit::Item::as_table_like)\n                                    .ok_or_else(|| {\n                                        anyhow::anyhow!(\"active profile is missing or malformed\")\n                                    })?;\n                                if table.contains_key(\"tui\") {\n                                    segments.extend([\"profiles\", profile]);\n                                }\n                            }\n                            segments.extend([\"tui\", row_key]);\n                            crate::config_persistence::set_document_value(doc, &segments, value)\n                        })?;\n                        Ok(path)\n                    });\n                match saved {\n                    Ok(path) => format!(\n                        \"{} {}\",\n                        tr(app.ui_locale, MessageId::ConfigScopeSaved),\n                        path.display()\n                    ),\n                    Err(error) => {\n                        return CommandResult::error(","sourceCodeStart":2470,"sourceCodeEnd":2506,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/commands/groups/config/config.rs#L2470-L2506","documentation":"While building the TOML edit path for a scoped config value, the active profile (`app.config_profile`) is either absent from the document's `profiles` table or is not a TOML table (malformed). The command errors instead of writing settings into a nonexistent profile section.","triggerScenarios":"set_config_value (crates/tui/src/commands/groups/config/config.rs:2488) reads the config TOML, looks up doc[\"profiles\"][profile], and it is missing or not a table_like while `app.config_profile` is Some — e.g. profile set in app state but never materialized in the file.","commonSituations":"Hand-edited config.toml that deleted or renamed the profile section, a profile name typo, a profile defined as a non-table value (e.g. string), or switching profiles in the UI before the profile was persisted.","solutions":["Check `profiles.<active-profile>` exists as a table in the config TOML","Correct the profile name typo or create the profile section","Ensure the profile value is a table, not a scalar","Recreate the profile via the config command so it materializes on disk"],"exampleFix":"// before\n[profiles]\nwork = \"oops\"\n// after\n[profiles.work.tui]\n# profile must be a table with its settings","handlingStrategy":"validation","validationCode":"// precheck: profile must exist as a table before scoped writes\nlet has_profile = doc.get(\"profiles\")\n    .and_then(|p| p.get(profile))\n    .and_then(toml_edit::Item::as_table_like)\n    .is_some();","typeGuard":null,"tryCatchPattern":"match set_config_value(app, key, value) {\n    Err(e) if e.to_string().contains(\"active profile is missing\") => {\n        eprintln!(\"Create [profiles.{}] in config first\", app.config_profile.unwrap_or_default());\n    }\n    other => other?,\n}","preventionTips":["Create the profile section before switching to it","Never delete profiles.<name> by hand while active","Keep profile values as TOML tables","Validate profile names against the document at switch time"],"tags":["config","toml","profile"],"backgroundTag":"missing-config-key","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T06:17:15.046Z"}