Hmbown/CodeWhale · error
expected an image block, got
Error message
expected an image block, got {other:?} What it means
Test-only panic: after matching ContentBlock::Text in expands_a_placeholder_into_an_image_block, the first block did not match any expected arm; the expansion emitted something other than the opening text tag naming the attached image path.
Solutions
- Ensure expand_attachment_blocks emits the open text tag as blocks[0] before the image block
- Inspect expanded.notices for attachment parse errors that change block shape
- Adjust the test's expected ordering only if the contract legitimately changed
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/tui/src/image_attach/tests.rs:287 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/7ee4d8075c93605d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/image_attach/tests.rs:287
let text = format!("look at this\n[Attached image: {}]", path.display());
let expanded = expand_attachment_blocks(&text);
assert!(expanded.notices.is_empty(), "{expanded:?}");
// Bracketed: open tag naming the path, the image, close tag.
assert_eq!(expanded.blocks.len(), 3, "{expanded:?}");
match &expanded.blocks[0] {
ContentBlock::Text { text, .. } => {
assert!(text.starts_with("<image path=\""), "{text}");
assert!(text.contains("shot.png"), "{text}");
}
other => panic!("expected an opening tag, got {other:?}"),
}
match &expanded.blocks[1] {
ContentBlock::ImageUrl { image_url } => {
assert!(image_url.url.starts_with("data:image/png;base64,"));
}
other => panic!("expected an image block, got {other:?}"),
}
assert_eq!(
expanded.blocks[2],
ContentBlock::Text {
text: "</image>".to_string(),
cache_control: None
}
);
}
#[test]
fn expands_multiple_placeholders_in_order() {
let dir = tempfile::tempdir().expect("tempdir");
let first = write_png(dir.path(), "one.png");
let second = write_png(dir.path(), "two.png");
std::fs::write(&second, [0xff, 0xd8, 0xff, 0xe0, 0x01]).expect("write jpeg");
let text = format!(
"[Attached image: {}]\nand\n[Attached image: {}]",View on GitHub (pinned to 433685b202)