You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(web): accept TIFF Exif and GPS pointers stored as IFD type 13 - #41526
When previewing a TIFF whose Exif or GPS pointer is stored as the standard IFD type (type 13) in the Files panel, the preview fails with "Unable to load image." libtiff, Adobe tools and other TIFF writers can store the ExifIFD (34665) and GPSIFD (34853) pointers this way (Adobe TIFF Technical Note 1).
validateTiffMetadata in imageDecode.worker.ts only accepts these two pointers as type 4 (LONG), so it rejects the file with tiff-metadata-pointer before the decoder runs. #41228 already taught the validator's type table about type 13 for SubIFDs, but this pointer check was left at type 4. The tiff decoder itself skips type-13 entries and decodes the image normally.
Change
The pointer check now accepts type 4 or type 13, still with exactly one value. The pointed IFD is validated exactly as before (bounds, depth, entry and allocation limits). Any other type or a count other than 1 is still rejected.
Scope
One condition in imageDecode.worker.ts, plus the existing WhiteIsZero TIFF case in AttachmentFilePreview.browser.test.tsx. It needs no issue because it is a small fix for an obvious bug: a valid TIFF fails to preview. SubIFDs and InteropIFD have no pointer-type check, so they already accept type 13. The desktop favicon reader's Exif orientation lookup (JPEG only) is a separate surface and is not touched.
Verification
An AI agent (T3 Code Nightly) ran each check below.
AttachmentFilePreview.browser.test.tsx: the WhiteIsZero TIFF case now adds a type-13 ExifIFD entry to its fixtures and checks that a SHORT pointer and a two-value pointer are still rejected. On 593885bd5df it fails with Error: Invalid TIFF metadata pointer.; on this branch it passes. vp run check:changed passes.
Real app, web client in Linux Chromium, fresh isolated dev data on each commit, no accounts needed.
Setup:vp run dev --no-seed, a project folder holding a 64×64 RGB TIFF whose ExifIFD pointer (34665) is type 13 and points at an Exif IFD. Pillow reads the pointer and its Exif IFD, and tiff@7.1.3 decodes the image.
Steps: open the project → Files panel → click the .tiff.
593885bd5df (before)
437027d9c47 (after)
The preview shows "Unable to load image." The decode worker reports tiff-metadata-pointer.
The 64 × 64 TIFF renders: an orange square on a black tile.
Pixels read back from the rendered preview after the fix: corner [5,5,5,255] and center [255,159,10,255], matching the file.
Fixture script (Node, no dependencies): node make-exif-ifd-tiff.mjs out.tiff
import{writeFileSync}from"node:fs";constout=process.argv[2];if(!out)thrownewError("usage: node make-exif-ifd-tiff.mjs <out.tiff>");constSHORT=3,LONG=4,UNDEFINED=7,IFD=13;constW=64,H=64;constifdSize=(n)=>2+n*12+4;constIFD0=8;constBPS=IFD0+ifdSize(11);// 146constEXIF=BPS+6;// 152constPIXELS=EXIF+ifdSize(1);// 170constbuffer=newArrayBuffer(PIXELS+W*H*3);constview=newDataView(buffer);constbytes=newUint8Array(buffer);view.setUint16(0,0x4949);view.setUint16(2,42,true);view.setUint32(4,IFD0,true);[8,8,8].forEach((bits,i)=>view.setUint16(BPS+i*2,bits,true));functionwriteIfd(offset,entries){view.setUint16(offset,entries.length,true);entries.forEach(([tag,type,value,count=1],index)=>{constentry=offset+2+index*12;view.setUint16(entry,tag,true);view.setUint16(entry+2,type,true);view.setUint32(entry+4,count,true);if(type===UNDEFINED)bytes.set(value,entry+8);elseif(type===SHORT&&count===1)view.setUint16(entry+8,value,true);elseview.setUint32(entry+8,value,true);});view.setUint32(offset+2+entries.length*12,0,true);}writeIfd(IFD0,[[256,SHORT,W],[257,SHORT,H],[258,SHORT,BPS,3],// BitsPerSample 8,8,8, stored out of line[259,SHORT,1],[262,SHORT,2],[273,LONG,PIXELS],[277,SHORT,3],[278,SHORT,H],[279,LONG,W*H*3],[284,SHORT,1],[34665,IFD,EXIF],// ExifIFD stored as type 13]);writeIfd(EXIF,[[0x9000,UNDEFINED,[...newTextEncoder().encode("0232")],4]]);// ExifVersion// Orange square on a near-black field.for(lety=0;y<H;y++)for(letx=0;x<W;x++){constinside=x>=16&&x<48&&y>=16&&y<48;bytes.set(inside ? [0xff,0x9f,0x0a] : [0x05,0x05,0x05],PIXELS+(y*W+x)*3);}writeFileSync(out,bytes);
Reviewing files that changed from the base of the PR and between 437027d and 325257c.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The TIFF metadata validator now accepts type-13 pointers with a value count of 1. Browser tests add ExifIFD metadata fixtures and check invalid pointer types, counts, and oversized or truncated metadata.
Changes: TIFF Pointer Validation
Layer / File(s)
Summary
Pointer validation and ExifIFD test coverage apps/web/src/components/files/imageDecode.worker.ts, apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx
The validator accepts pointer types 4 and 13 when the value count is 1. Tests add type-13 ExifIFD pointers and check invalid pointer types, counts, and oversized or truncated metadata.
TIFF previews with Exif or GPS pointers stored as type 13 should now load instead of showing "Unable to load image." Invalid pointer types and counts are still rejected. No concrete merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(web): accept TIFF Exif and GPS pointers stored as IFD type 13" states the primary change. The raw summary shows imageDecode.worker.ts now accepts type 13 for TIFF pointer tags with a co…
Description check
The description follows the template. It has Problem, Change, Scope, and Verification sections, and each contains specific content. The Problem explains the expected and actual behavior with the TIFF …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix(web): accept TIFF Exif and GPS pointers stored as IFD type 13" states the primary change. The raw summary shows imageDecode.worker.ts now accepts type 13 for TIFF pointer tags with a count of 1, and the test file covers the Exif pointer case. The title is specific, follows the conventional commit style, and matches the objectives. It is slightly narrower than the full change because it names Exif and GPS, while the summary mentions only the pointer check generally; this is a minor point.
Full details: Description check
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections, and each contains specific content. The Problem explains the expected and actual behavior with the TIFF type 13 pointer and the tiff-metadata-pointer error. The Change explains the type 4 or type 13 acceptance with count 1. The Scope names the touched files, explains why no issue is linked, and notes the out-of-scope favicon reader. Verification gives the failing and passing test results, the Linux Chromium real-app steps, before and after evidence, and pixel values. The description has a minor gap: the Scope section does not link an issue, but it gives a reason for the lack of one, as the template allows for small obvious bugs. The template's agent attribution line is present.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Seed the same synthetic TIFF project and Replay thread on each commit, open Files, and select exif-type13.tiff. Web browser, fresh isolated state, light theme, 1440×1000.
The scenario runner exited 0: failed on base and passed on head.
Not shown:
GPSIFD type-13 pointers and rejection of invalid pointer types, counts, or metadata were not exercised in the real app; this scenario covers the reported ExifIFD rendering failure.
The type-4 control TIFF was generated but not opened in this scenario.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:XS0-9 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When previewing a TIFF whose Exif or GPS pointer is stored as the standard IFD type (type 13) in the Files panel, the preview fails with "Unable to load image." libtiff, Adobe tools and other TIFF writers can store the
ExifIFD(34665) andGPSIFD(34853) pointers this way (Adobe TIFF Technical Note 1).validateTiffMetadatainimageDecode.worker.tsonly accepts these two pointers as type 4 (LONG), so it rejects the file withtiff-metadata-pointerbefore the decoder runs. #41228 already taught the validator's type table about type 13 forSubIFDs, but this pointer check was left at type 4. Thetiffdecoder itself skips type-13 entries and decodes the image normally.Change
The pointer check now accepts type 4 or type 13, still with exactly one value. The pointed IFD is validated exactly as before (bounds, depth, entry and allocation limits). Any other type or a count other than 1 is still rejected.
Scope
One condition in
imageDecode.worker.ts, plus the existing WhiteIsZero TIFF case inAttachmentFilePreview.browser.test.tsx. It needs no issue because it is a small fix for an obvious bug: a valid TIFF fails to preview.SubIFDsandInteropIFDhave no pointer-type check, so they already accept type 13. The desktop favicon reader's Exif orientation lookup (JPEG only) is a separate surface and is not touched.Verification
An AI agent (T3 Code Nightly) ran each check below.
AttachmentFilePreview.browser.test.tsx: the WhiteIsZero TIFF case now adds a type-13ExifIFDentry to its fixtures and checks that a SHORT pointer and a two-value pointer are still rejected. On593885bd5dfit fails withError: Invalid TIFF metadata pointer.; on this branch it passes.vp run check:changedpasses.Real app, web client in Linux Chromium, fresh isolated dev data on each commit, no accounts needed.
Setup:
vp run dev --no-seed, a project folder holding a 64×64 RGB TIFF whoseExifIFDpointer (34665) is type 13 and points at an Exif IFD. Pillow reads the pointer and its Exif IFD, andtiff@7.1.3decodes the image.Steps: open the project → Files panel → click the
.tiff.593885bd5df(before)437027d9c47(after)tiff-metadata-pointer.Pixels read back from the rendered preview after the fix: corner
[5,5,5,255]and center[255,159,10,255], matching the file.Fixture script (Node, no dependencies):
node make-exif-ifd-tiff.mjs out.tiffGenerated with Gemini 4 Neon in T3 Code Nightly