Guard exifread 3.x IndexError on empty DJI MakerNote values#2021
Open
jrstear wants to merge 1 commit intoOpenDroneMap:masterfrom
Open
Guard exifread 3.x IndexError on empty DJI MakerNote values#2021jrstear wants to merge 1 commit intoOpenDroneMap:masterfrom
jrstear wants to merge 1 commit intoOpenDroneMap:masterfrom
Conversation
exifread 3.x (through 3.5.1) raises IndexError in ExifHeader._get_printable_for_field when it encounters a MakerNote tag with an empty values list. This occurs with some DJI drone images (e.g. DJI M3E) and causes ODM to crash during EXIF parsing. Monkeypatches _get_printable_for_field with a try/except IndexError guard. This is preferable to forking exifread or pinning an older version, and can be removed when exifread upstream fixes the issue. Tested with DJI M3E imagery (1393 images, Aztec Highway survey). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Monkeypatches
exifread.core.exif_header.ExifHeader._get_printable_for_fieldinopendm/photo.pyto catchIndexErrorraised by ExifRead 3.x when a MakerNote tag has an emptyvalueslist.Some DJI drones (confirmed on DJI M3E) emit MakerNote tags where the decoded values list is empty. ExifRead does
str(values[0])without a length guard, which raisesIndexErrorand kills ODM at the dataset stage.Root cause
Upstream bug in exifread 3.x (3.0 through at least 3.5.1). Filed upstream: ianare/exif-py#254 — happy to open the one-line fix as a PR there too; the guard is equivalent to
str(values[0]) if values else \"\".Why a monkeypatch here
return \"\") — same visible behavior as a well-formed empty tag.opendm/photo.py), so it's easy to remove once the exifread release lands. ATODO-style comment points back to the upstream issue.Validation
Tested end-to-end against a 1385-image DJI M3E survey (Aztec Highway corridor, New Mexico):
IndexError: list index out of rangeon the first offending image.No regression on non-DJI imagery in our local tests (all previous ODM runs continued to work).
Scope
Single-file change, no new deps, no flags, no public-API changes.
Affected versions
ExifRead 3.0 → 3.5.1 (at minimum). When upstream ships a fix, this block can be removed.