{"record":{"id":"5bb6dfd8995e96a7","repo":"Hmbown/CodeWhale","slug":"load-config-store","errorCode":null,"errorMessage":"load config store","messagePattern":"load config store","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/config/src/tests.rs","lineNumber":4220,"sourceCode":"    )\n    .expect(\"seed backup\");\n\n    scrub_plaintext_api_keys_from_config_backup(&path).expect(\"scrub backup\");\n\n    let backup = fs::read_to_string(backup_path).expect(\"read backup\");\n    assert!(!backup.contains(\"old-test-credential\"), \"{backup}\");\n    assert!(!backup.contains(\"api_key\"), \"{backup}\");\n    assert!(backup.contains(\"model = \\\"old-model\\\"\"));\n}\n\n#[test]\nfn config_store_save_preserves_comments() {\n    let dir = tempfile::tempdir().expect(\"tempdir\");\n    let config_path = dir.path().join(CONFIG_FILE_NAME);\n    let original = \"# my model\\nmodel = \\\"deepseek-v4-flash\\\"\\n# end comment\\n\";\n    fs::write(&config_path, original).expect(\"write config\");\n\n    let mut store = ConfigStore::load(Some(config_path.clone())).expect(\"load config store\");\n    store.config.model = Some(\"deepseek-v4-pro\".to_string());\n    store.save().expect(\"save\");\n\n    let body = fs::read_to_string(&config_path).expect(\"read config\");\n    assert!(body.contains(\"# my model\"), \"prefix comment preserved\");\n    assert!(body.contains(\"# end comment\"), \"suffix comment preserved\");\n    assert!(body.contains(\"model = \\\"deepseek-v4-pro\\\"\"));\n}\n\n#[test]\nfn config_store_save_preserves_disabled_keys() {\n    let dir = tempfile::tempdir().expect(\"tempdir\");\n    let config_path = dir.path().join(CONFIG_FILE_NAME);\n    fs::write(\n        &config_path,\n        \"# my note\\nmodel = \\\"deepseek-v4-flash\\\"\\n# base_url = \\\"http://localhost:11434/v1\\\"\\n\",\n    )\n    .expect(\"write config\");","sourceCodeStart":4202,"sourceCodeEnd":4238,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/config/src/tests.rs#L4202-L4238","documentation":"ConfigStore::load(Some(config_path.clone())).expect(\"load config store\") in the same test panics when loading the seeded config fails — invalid TOML, an IO error, or a schema validation error inside ConfigStore. This is the real signal when fixture content and the loader's expected schema drift.","triggerScenarios":"The seeded TOML (\"# my model\\nmodel = \\\"deepseek-v4-flash\\\"\\n# end comment\\n\") no longer parses or validates after a Config struct change (renamed/typed fields); the file was not written by the previous fixture step.","commonSituations":"Adding a required field to Config without a serde default breaks old fixtures; typo'd TOML in a hand-edited test string; config file path passed incorrectly to load.","solutions":["Read the inner error in the panic: parse error -> fix the fixture TOML; missing field -> add #[serde(default)] or update the fixture.","If a new required Config field was introduced, update test fixtures (or add a serde default) rather than bending the loader.","Confirm config_path exists before load; keep the tempdir alive across the test."],"exampleFix":"// before\nlet original = \"# my model\\nmodel = \\\"deepseek-v4-flash\\\"\\n# end comment\\n\";\n// after (new required field added to Config)\nlet original = \"# my model\\nmodel = \\\"deepseek-v4-flash\\\"\\napi_key_env = \\\"KEY\\\"\\n# end comment\\n\";","handlingStrategy":"validation","validationCode":"// validate fixture before loading\nlet _probe: toml::Value = toml::from_str(original).expect(\"fixture must be valid TOML\");","typeGuard":null,"tryCatchPattern":"let store = ConfigStore::load(Some(config_path.clone()))\n    .unwrap_or_else(|e| panic!(\"load config store failed: {e}; check fixture TOML vs Config schema\"));","preventionTips":["When adding a required Config field, give it #[serde(default)] or update all test fixtures","Probe fixture strings with toml::from_str in a unit test","Keep tempdir alive and verify the file exists before load"],"tags":["test","config","toml","deserialization"],"backgroundTag":"config-file-not-found","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}