Skip to content

Guard exifread 3.x IndexError on empty DJI MakerNote values#2021

Open
jrstear wants to merge 1 commit intoOpenDroneMap:masterfrom
jrstear:fix/exifread-makernote-indexerror
Open

Guard exifread 3.x IndexError on empty DJI MakerNote values#2021
jrstear wants to merge 1 commit intoOpenDroneMap:masterfrom
jrstear:fix/exifread-makernote-indexerror

Conversation

@jrstear
Copy link
Copy Markdown

@jrstear jrstear commented Apr 17, 2026

Summary

Monkeypatches exifread.core.exif_header.ExifHeader._get_printable_for_field in opendm/photo.py to catch IndexError raised by ExifRead 3.x when a MakerNote tag has an empty values list.

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 raises IndexError and 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

  • Small (13 lines), no new dependency, no exifread fork/pin.
  • Fails closed (return \"\") — same visible behavior as a well-formed empty tag.
  • Isolated to ODM's EXIF entry point (opendm/photo.py), so it's easy to remove once the exifread release lands. A TODO-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):

  • Without patch (stock v3.6.0): dataset stage crashes with IndexError: list index out of range on the first offending image.
  • With patch: full pipeline completes through orthophoto generation; EXIF metadata for affected tags is emitted as empty (the same behavior users would see for a legitimately empty tag).

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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant