{"record":{"id":"b943829a7af2687a","repo":"Hmbown/CodeWhale","slug":"save","errorCode":null,"errorMessage":"save","messagePattern":"save","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/tests.rs","lineNumber":4222,"sourceCode":"\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\");\n\n    let mut store = ConfigStore::load(Some(config_path.clone())).expect(\"load config store\");","sourceCodeStart":4204,"sourceCodeEnd":4240,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/config/src/tests.rs#L4204-L4240","documentation":"A test-only expect(\"save\") panic in config tests: the ConfigStore save under test returned an Err instead of Ok. It indicates the save path itself failed (permissions, unwritable temp dir, or serialization of the TOML body), not an assertion about content — content checks come later via reading the file back.","triggerScenarios":"Thrown at crates/config/src/tests.rs:4222 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the returned io::Error to see whether the temp dir was unwritable or the TOML render failed","Ensure the test writes into a fresh tempfile::tempdir so no stale/locked file blocks the save","If serialization failed, fix the config values the test constructs so they render to valid TOML"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}