{"record":{"id":"b0f38554c5e00e56","repo":"Hmbown/CodeWhale","slug":"the-report-must-name-the-failing-pair","errorCode":null,"errorMessage":"the report must name the failing pair","messagePattern":"the report must name the failing pair","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/palette/src/tests.rs","lineNumber":1165,"sourceCode":"        }\n    }\n}\n\n#[test]\nfn violation_report_names_pair_and_ratio() {\n    let mut bad = TOKYO_NIGHT_UI_THEME;\n    bad.text_muted = bad.surface_bg;\n    let violations = theme_contrast_violations(&bad);\n    // The muted-on-surface color fails against all four text surfaces.\n    let muted_pairs: Vec<_> = violations\n        .iter()\n        .filter(|violation| violation.pair.starts_with(\"text_muted on \"))\n        .collect();\n    assert_eq!(muted_pairs.len(), 4);\n    let violation = violations\n        .iter()\n        .find(|violation| violation.pair == \"text_muted on surface_bg\")\n        .expect(\"the report must name the failing pair\");\n    assert_eq!(violation.fg, bad.text_muted);\n    assert_eq!(violation.bg, bad.surface_bg);\n    // Identical colors sit at 1:1 — far under the floor the report carries.\n    assert!(violation.ratio < 1.1);\n    assert!(violation.ratio < violation.floor);\n    assert_eq!(violation.floor, AA_BODY_CONTRAST);\n}\n\n#[test]\nfn direct_field_paint_follows_the_terminal_owned_shell() {\n    // Widgets that paint `bg(WHALE_BG)` directly follow the theme's shell\n    // instead of laying a navy patch over the terminal's own ground.\n    assert_eq!(\n        adapt_bg_for_theme(WHALE_BG, ThemeId::Whale, &UI_THEME),\n        Color::Reset\n    );\n    assert_eq!(\n        adapt_bg_for_theme(WHALE_BG, ThemeId::WhaleLight, &LIGHT_UI_THEME),","sourceCodeStart":1147,"sourceCodeEnd":1183,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/palette/src/tests.rs#L1147-L1183","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","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.","If text_muted now passes on surface_bg, regenerate the deliberately-bad theme fixture so it still violates the AA_BODY_CONTRAST floor."],"exampleFix":"// before\n.find(|violation| violation.pair == \"text_muted on surface_bg\")\n.expect(\"the report must name the failing pair\");\n// after\n.find(|violation| violation.pair == \"text_muted on surface_bg\")\n.unwrap_or_else(|| panic!(\n    \"report missing pair 'text_muted on surface_bg'; got {:?}\",\n    violations.iter().map(|v| &v.pair).collect::<Vec<_>>()\n));","handlingStrategy":"validation","validationCode":"assert!(\n    violations.iter().any(|v| v.pair == \"text_muted on surface_bg\"),\n    \"report pairs: {:?}\",\n    violations.iter().map(|v| &v.pair).collect::<Vec<_>>()\n);","typeGuard":null,"tryCatchPattern":"let violation = violations.iter().find(|v| v.pair == \"text_muted on surface_bg\")\n    .unwrap_or_else(|| panic!(\"violation report omitted expected pair; got {:?}\",\n        violations.iter().map(|v| &v.pair).collect::<Vec<_>>()));","preventionTips":["Treat the 'fg on bg' pair string as API: add a formatter function so test and report share one source of truth.","Keep the audit loop covering all surfaces; add a count assertion (e.g. muted_pairs.len() == 4) before the find.","When changing the bad-theme fixture, re-check that text_muted still violates AA_BODY_CONTRAST on at least surface_bg."],"tags":["rust","option-unwrap-panic","accessibility","contrast-audit"],"backgroundTag":"empty-result-set","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"}