Hmbown/CodeWhale · error

the report must name the failing pair

Error message

the report must name the failing pair

What it means

This is a Rust `Option::expect` panic reading 'the report must name the failing pair': the contrast violation report produced no entry whose `pair` equals "text_muted on surface_bg", so `find` returned None and the test aborted. The library throws it when the violation report generator fails to record a known-bad foreground/background combination — usually because the pair naming changed, the pair was filtered out, or the muted foreground was not evaluated against every surface. It asserts the report's contract: it must name each failing pair, its fg/bg colors, the measured ratio, and the floor.

Solutions

  1. Print the actual violation pair names and update the test's expected string to the report's current format, or restore the 'fg on bg' naming contract if it is public API.
  2. Ensure the report iterates text_muted against all four surfaces (surface_bg, panel_bg, composer_bg, elevated_bg) so the known-bad pair is always recorded.
  3. If text_muted now passes on surface_bg, regenerate the deliberately-bad theme fixture so it still violates the AA_BODY_CONTRAST floor.

Example fix

// before
.find(|violation| violation.pair == "text_muted on surface_bg")
.expect("the report must name the failing pair");
// after
.find(|violation| violation.pair == "text_muted on surface_bg")
.unwrap_or_else(|| panic!(
    "report missing pair 'text_muted on surface_bg'; got {:?}",
    violations.iter().map(|v| &v.pair).collect::<Vec<_>>()
));
Defensive patterns

Strategy: validation

Validate before calling

assert!(
    violations.iter().any(|v| v.pair == "text_muted on surface_bg"),
    "report pairs: {:?}",
    violations.iter().map(|v| &v.pair).collect::<Vec<_>>()
);

Try / catch

let violation = violations.iter().find(|v| v.pair == "text_muted on surface_bg")
    .unwrap_or_else(|| panic!("violation report omitted expected pair; got {:?}",
        violations.iter().map(|v| &v.pair).collect::<Vec<_>>()));

Prevention

When it happens

Trigger: Running the violation report over a deliberately bad grayscale theme and then searching `violations.iter().find(|v| v.pair == "text_muted on surface_bg")` when (a) the report renamed pairs (different separator or surface key), (b) text_muted no longer falls below AA_BODY_CONTRAST on surface_bg, or (c) the surface loop was narrowed so surface_bg was never checked. Any of these leaves `find` empty and panics.

Common situations: Refactoring the `pair` string format (e.g. 'text_muted/surface_bg' instead of ' on ') while tests still match the literal; dropping a surface from the audit loop; changing the muted color so it accidentally passes, removing the violation the test expects.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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

Appendix: source

Thrown at crates/palette/src/tests.rs:1165

        }
    }
}

#[test]
fn violation_report_names_pair_and_ratio() {
    let mut bad = TOKYO_NIGHT_UI_THEME;
    bad.text_muted = bad.surface_bg;
    let violations = theme_contrast_violations(&bad);
    // The muted-on-surface color fails against all four text surfaces.
    let muted_pairs: Vec<_> = violations
        .iter()
        .filter(|violation| violation.pair.starts_with("text_muted on "))
        .collect();
    assert_eq!(muted_pairs.len(), 4);
    let violation = violations
        .iter()
        .find(|violation| violation.pair == "text_muted on surface_bg")
        .expect("the report must name the failing pair");
    assert_eq!(violation.fg, bad.text_muted);
    assert_eq!(violation.bg, bad.surface_bg);
    // Identical colors sit at 1:1 — far under the floor the report carries.
    assert!(violation.ratio < 1.1);
    assert!(violation.ratio < violation.floor);
    assert_eq!(violation.floor, AA_BODY_CONTRAST);
}

#[test]
fn direct_field_paint_follows_the_terminal_owned_shell() {
    // Widgets that paint `bg(WHALE_BG)` directly follow the theme's shell
    // instead of laying a navy patch over the terminal's own ground.
    assert_eq!(
        adapt_bg_for_theme(WHALE_BG, ThemeId::Whale, &UI_THEME),
        Color::Reset
    );
    assert_eq!(
        adapt_bg_for_theme(WHALE_BG, ThemeId::WhaleLight, &LIGHT_UI_THEME),

View on GitHub (pinned to 433685b202)