Skip to content

GeoTIFF reader: upgrade non-finite/fractional int nodata from silent no-op to typed rejection (#1774 follow-up) #2441

Closed

Description

@brendancol

Describe the bug

When a GeoTIFF's GDAL_NODATA tag holds a non-finite string ("NaN", "Inf", "-Inf") or a fractional value ("3.5") on an integer-dtype file, the reader silently skips the masking step, preserves the dtype, and puts the raw sentinel on attrs['nodata']. #1774 introduced that no-op to stop the crash from int(float('nan')), but the silent skip is itself a problem: a caller downstream of open_geotiff cannot tell the difference between "no sentinel was declared" and "sentinel was declared and the reader ignored it". Pixels the caller expected to see as NaN are still raw integer values.

The geotiff release contract pins this in xrspatial/geotiff/tests/release_gates/test_stable_features.py::test_release_gate_negative_integer_nodata_float_promoted (currently xfailed). The contract says the reader should upgrade the no-op to a typed GeoTIFFAmbiguousMetadataError so the silent-coercion risk surfaces at the read boundary.

Expected behavior

Reading an integer GeoTIFF whose GDAL_NODATA tag is non-finite or fractional raises GeoTIFFAmbiguousMetadataError by default. The message names nodata and points at an allow_invalid_nodata=True opt-in that preserves the existing no-op behavior for callers whose files legitimately carry such sentinels.

Tracking

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginput-validationInput validation and error messages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions