Hmbown/CodeWhale · error
expected an opening tag, got
Error message
expected an opening tag, got {other:?} What it means
Test-only panic in expands_a_placeholder_into_an_image_block: the first expanded block was not the expected ContentBlock::Text open tag (e.g. it came back as an ImageUrl or other variant), so the placeholder expansion produced an unexpected block ordering.
Solutions
- Fix expand_attachment_blocks so the first block is always the textual '<image path=...>' open tag when a placeholder is expanded
- Check the expanded.notices field for parse failures that shift blocks
- Update the match arms if the block contract intentionally changed
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/tui/src/image_attach/tests.rs:281 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/2db9d3987c970027.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/image_attach/tests.rs:281
}
#[test]
fn expands_a_placeholder_into_an_image_block() {
let dir = tempfile::tempdir().expect("tempdir");
let path = write_png(dir.path(), "shot.png");
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() {View on GitHub (pinned to 433685b202)