{"record":{"id":"e2efdd044f10a034","repo":"Hmbown/CodeWhale","slug":"expected-replacement-text-got-other","errorCode":null,"errorMessage":"expected replacement text, got {other:?}","messagePattern":"expected replacement text, got (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/image_attach/tests.rs","lineNumber":389,"sourceCode":"\n    let stripped =\n        strip_images_when_unsupported(&mut messages, SupportState::Unsupported, \"deepseek-chat\");\n\n    assert_eq!(stripped, 1);\n    assert!(\n        !messages[0]\n            .content\n            .iter()\n            .any(|block| matches!(block, ContentBlock::ImageUrl { .. })),\n        \"no image may survive to a route that cannot read one\"\n    );\n    match &messages[0].content[0] {\n        ContentBlock::Text { text, .. } => {\n            assert!(text.contains(\"deepseek-chat\"), \"{text}\");\n            assert!(text.contains(\"/model\"), \"{text}\");\n            assert!(text.contains(\"omitted\"), \"{text}\");\n        }\n        other => panic!(\"expected replacement text, got {other:?}\"),\n    }\n}\n\n#[test]\nfn a_supported_or_unknown_route_keeps_its_images() {\n    // Unknown is the common case: models.dev has no modality data for most\n    // routes. Stripping there would make the feature dead on arrival for\n    // self-hosted and custom providers.\n    for vision in [SupportState::Supported, SupportState::Unknown] {\n        let mut messages = vec![message_with_image(\"data:image/png;base64,QUJD\")];\n\n        let stripped = strip_images_when_unsupported(&mut messages, vision, \"some-model\");\n\n        assert_eq!(stripped, 0, \"{vision:?} must not strip\");\n        assert!(\n            messages[0]\n                .content\n                .iter()","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/image_attach/tests.rs#L371-L407","documentation":"Test-only panic in a_blind_route_gets_text_in_place_of_every_image: after stripping images for an unsupported route, messages[0].content[0] was not a ContentBlock::Text, meaning strip_images_when_unsupported did not replace the first image with the expected text fallback naming the model and /model command.","triggerScenarios":"Thrown at crates/tui/src/image_attach/tests.rs:389 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make strip_images_when_unsupported replace each ImageUrl block with a Text block at the same position","Verify the SupportState was actually Unsupported for the model passed","Check notices produced during stripping for clues about skipped replacements"],"exampleFix":null,"handlingStrategy":"type-guard","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"}