{"record":{"id":"abaf0e2d25a045e2","repo":"Hmbown/CodeWhale","slug":"expected-unsupportedformat-for-name-got-other","errorCode":null,"errorMessage":"expected UnsupportedFormat for {name}, got {other:?}","messagePattern":"expected UnsupportedFormat for (.+?), got (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/image_attach/tests.rs","lineNumber":194,"sourceCode":"    at_limit.resize(MAX_IMAGE_BYTES, 0);\n    assert!(encode_image_bytes(&at_limit, \"edge.png\").is_ok());\n}\n\n#[test]\nfn rejects_a_real_image_in_an_unsupported_format_by_name() {\n    for (bytes, name) in [\n        (b\"BM\\x00\\x00\\x00\\x00\".as_slice(), \"BMP\"),\n        (b\"II\\x2a\\x00extra\".as_slice(), \"TIFF\"),\n        (b\"MM\\x00\\x2aextra\".as_slice(), \"TIFF\"),\n        (b\"<svg xmlns=\".as_slice(), \"SVG\"),\n        (b\"%PDF-1.7\".as_slice(), \"PDF\"),\n    ] {\n        let error = encode_image_bytes(bytes, \"f\").expect_err(\"must reject\");\n        match error {\n            ImageAttachError::UnsupportedFormat { detected, .. } => {\n                assert_eq!(detected, name);\n            }\n            other => panic!(\"expected UnsupportedFormat for {name}, got {other:?}\"),\n        }\n    }\n}\n\n#[test]\nfn rejects_a_file_that_is_not_an_image_at_all() {\n    let error = encode_image_bytes(b\"#!/bin/sh\\necho hi\\n\", \"script.png\").expect_err(\"must reject\");\n    assert!(\n        matches!(error, ImageAttachError::NotAnImage { .. }),\n        \"got {error:?}\"\n    );\n}\n\n#[test]\nfn rejects_an_empty_file() {\n    let error = encode_image_bytes(b\"\", \"empty.png\").expect_err(\"must reject\");\n    assert!(\n        matches!(error, ImageAttachError::Empty { .. }),","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/image_attach/tests.rs#L176-L212","documentation":"Test assertion in rejects_a_real_image_in_an_unsupported_format_by_name: encode_image_bytes was expected to return ImageAttachError::UnsupportedFormat for the given magic bytes (BMP/TIFF/SVG/PDF fixtures), but returned a different error variant. This fires when format detection misclassifies a rejected-by-name format — e.g. reporting a size or decode error instead of UnsupportedFormat with the detected format name.","triggerScenarios":"Thrown at crates/tui/src/image_attach/tests.rs:194 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect which error variant encode_image_bytes actually returned for the failing fixture","Verify the magic-byte sniffing order detects BMP ('BM'), TIFF ('II*'/'MM*'), SVG ('<svg'), and PDF ('%PDF-') before falling back to decode attempts","Ensure unsupported-format detection runs by name/magic bytes prior to any pixel decoding"],"exampleFix":null,"handlingStrategy":"fallback","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"}