Hmbown/CodeWhale · error

read config

Error message

read config

What it means

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.

Solutions

  1. Check that the preceding write/save actually succeeded and targeted the same path
  2. Verify the expected file path matches where the code under test writes (file name, directory, symlinks)
  3. If the file exists but is invalid UTF-8, fix whatever produced non-UTF-8 bytes
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/config/src/tests.rs:4224 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/22c2407628da8ccd. Report an issue: GitHub.

Appendix: source

Thrown at crates/config/src/tests.rs:4224

    let backup = fs::read_to_string(backup_path).expect("read backup");
    assert!(!backup.contains("old-test-credential"), "{backup}");
    assert!(!backup.contains("api_key"), "{backup}");
    assert!(backup.contains("model = \"old-model\""));
}

#[test]
fn config_store_save_preserves_comments() {
    let dir = tempfile::tempdir().expect("tempdir");
    let config_path = dir.path().join(CONFIG_FILE_NAME);
    let original = "# my model\nmodel = \"deepseek-v4-flash\"\n# end comment\n";
    fs::write(&config_path, original).expect("write config");

    let mut store = ConfigStore::load(Some(config_path.clone())).expect("load config store");
    store.config.model = Some("deepseek-v4-pro".to_string());
    store.save().expect("save");

    let body = fs::read_to_string(&config_path).expect("read config");
    assert!(body.contains("# my model"), "prefix comment preserved");
    assert!(body.contains("# end comment"), "suffix comment preserved");
    assert!(body.contains("model = \"deepseek-v4-pro\""));
}

#[test]
fn config_store_save_preserves_disabled_keys() {
    let dir = tempfile::tempdir().expect("tempdir");
    let config_path = dir.path().join(CONFIG_FILE_NAME);
    fs::write(
        &config_path,
        "# my note\nmodel = \"deepseek-v4-flash\"\n# base_url = \"http://localhost:11434/v1\"\n",
    )
    .expect("write config");

    let mut store = ConfigStore::load(Some(config_path.clone())).expect("load config store");
    store.config.model = Some("deepseek-v4-pro".to_string());
    store.save().expect("save");

View on GitHub (pinned to 433685b202)