{"record":{"id":"22c2407628da8ccd","repo":"Hmbown/CodeWhale","slug":"read-config","errorCode":null,"errorMessage":"read config","messagePattern":"read config","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/tests.rs","lineNumber":4224,"sourceCode":"\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\");\n    store.config.model = Some(\"deepseek-v4-pro\".to_string());\n    store.save().expect(\"save\");","sourceCodeStart":4206,"sourceCodeEnd":4242,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/config/src/tests.rs#L4206-L4242","documentation":"A test-only expect(\"read config\") panic: fs::read_to_string on the config file returned an Err. In these tests it fires when the file the test just wrote (or that ConfigStore was expected to write) is missing, unreadable, or not valid UTF-8 — i.e. the test's setup or the save under test did not produce the expected file on disk.","triggerScenarios":"Thrown at crates/config/src/tests.rs:4224 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the preceding write/save actually succeeded and targeted the same path","Verify the expected file path matches where the code under test writes (file name, directory, symlinks)","If the file exists but is invalid UTF-8, fix whatever produced non-UTF-8 bytes"],"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"}