Skip to content

geotiff: guard streaming writer against MinIsWhite extra_tags override#2080

Merged
brendancol merged 2 commits into
mainfrom
issue-2073
May 18, 2026
Merged

geotiff: guard streaming writer against MinIsWhite extra_tags override#2080
brendancol merged 2 commits into
mainfrom
issue-2073

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #2073

Summary

  • Mirror the eager writer's MinIsWhite extra_tags guard inside write_streaming so a dask write with extra_tags=[(262, SHORT, 1, 0)] on a single-band raster raises ValueError instead of writing inverted bytes.
  • Pin two regressions: the override is rejected with a message naming extra_tags and photometric; a non-MinIsWhite-crossing override (photometric=1) still round-trips.

Backend coverage

  • Dask path (xrspatial/geotiff/_writer.py::write_streaming). The eager path already had the guard at _writer.py:1600-1617; no change there.

Test plan

  • pytest xrspatial/tests/test_geotiff_streaming_photometric_override_2073.py -x -q (2 passed)
  • pytest xrspatial/tests/test_geotiff*.py -x -q (12 passed)
  • Wider sweep pytest xrspatial/geotiff/ xrspatial/tests/ -k "geotiff or photometric or extra_tags" -- only failures are pre-existing GPU tests (test_predictor2_big_endian_gpu_1517, test_size_param_validation_gpu_vrt_1776::test_tile_size_positive_works) unrelated to the photometric path.

…erride (#2073)

The eager writer rejects extra_tags overrides that would require
writer-side pixel inversion for single-band MinIsWhite. The streaming
dask path lacked the same guard, so an override silently bypassed the
inversion and the file round-tripped with inverted pixel values.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 18, 2026
…2073)

Address PR #2080 review:

* Factor the duplicated TAG_PHOTOMETRIC-override guard out of the
  eager and streaming writers into
  ``_reject_disagreeing_photometric_override``. Both writers now
  call the helper, so the message text, the gating condition, and
  the single-band scope live in one place.

* Add ``test_streaming_extra_tags_miniswhite_override_multiband_not_rejected_2073``
  to pin the ``samples == 1`` gate. A regression that dropped or
  flipped the gate (so the guard fired for multi-band rasters too)
  would otherwise surface only by accident.

* Move the regression test from ``xrspatial/tests/`` to
  ``xrspatial/geotiff/tests/`` to match every other geotiff
  regression test's location. Filename also shortened: the
  ``geotiff_`` prefix was redundant inside the geotiff subtree.

The third dismissed nit (``_extra_tags_photo_ds`` naming) goes
away with the refactor because the helper takes its own local
variable name.
@brendancol brendancol merged commit b883a38 into main May 18, 2026
4 of 5 checks passed
@brendancol brendancol deleted the issue-2073 branch May 27, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dask streaming writer: silent corruption when extra_tags overrides TAG_PHOTOMETRIC for MinIsWhite single-band raster

1 participant