Reject overview_level / on_gpu_failure on VRT sources (#1685)#1689
Merged
brendancol merged 2 commits intoMay 12, 2026
Merged
Conversation
brendancol
added a commit
to brendancol/xarray-spatial
that referenced
this pull request
May 12, 2026
Three MEDIUM findings filed and fixed: xarray-contrib#1683 (bigtiff docstring gap on to_geotiff), xarray-contrib#1684 (write_vrt nodata float|None widened to float|int|None), and xarray-contrib#1685 (open_geotiff silently dropped overview_level / on_gpu_failure on VRT sources). PRs xarray-contrib#1686, xarray-contrib#1687, and xarray-contrib#1689. cuda-validated.
brendancol
added a commit
to brendancol/xarray-spatial
that referenced
this pull request
May 12, 2026
Three MEDIUM findings filed and fixed: xarray-contrib#1683 (bigtiff docstring gap on to_geotiff), xarray-contrib#1684 (write_vrt nodata float|None widened to float|int|None), and xarray-contrib#1685 (open_geotiff silently dropped overview_level / on_gpu_failure on VRT sources). PRs xarray-contrib#1686, xarray-contrib#1687, and xarray-contrib#1689. cuda-validated.
brendancol
added a commit
to brendancol/xarray-spatial
that referenced
this pull request
May 12, 2026
Three MEDIUM findings filed and fixed: xarray-contrib#1683 (bigtiff docstring gap on to_geotiff), xarray-contrib#1684 (write_vrt nodata float|None widened to float|int|None), and xarray-contrib#1685 (open_geotiff silently dropped overview_level / on_gpu_failure on VRT sources). PRs xarray-contrib#1686, xarray-contrib#1687, and xarray-contrib#1689. cuda-validated.
brendancol
added a commit
that referenced
this pull request
May 12, 2026
* Document bigtiff kwarg in to_geotiff docstring (#1683) The Parameters block jumped from overview_resampling to gpu, omitting the bigtiff entry that has been on the signature for several releases. write_geotiff_gpu documents the same kwarg, so callers who learned the API from the GPU writer and ported a call to to_geotiff had no way to discover the option from help(to_geotiff). Pin the entry against future drift with a test that walks the Parameters block and compares it to inspect.signature(). * Update api-consistency sweep state for geotiff v2 (2026-05-12) Three MEDIUM findings filed and fixed: #1683 (bigtiff docstring gap on to_geotiff), #1684 (write_vrt nodata float|None widened to float|int|None), and #1685 (open_geotiff silently dropped overview_level / on_gpu_failure on VRT sources). PRs #1686, #1687, and #1689. cuda-validated.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an API-consistency gap in xrspatial.geotiff.open_geotiff where VRT sources previously routed through read_vrt and silently ignored overview_level / on_gpu_failure. It makes those unsupported kwarg combinations fail loudly (with ValueError) and adds regression coverage to prevent future silent kwarg drops.
Changes:
- Add VRT-specific validation in
open_geotiffto rejectoverview_levelandon_gpu_failurebefore dispatching toread_vrt. - Add regression tests ensuring VRT calls raise on unsupported kwargs and that non-VRT
.tifsources still acceptoverview_level. - Update the internal API-consistency sweep state CSV entry.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
xrspatial/geotiff/__init__.py |
Adds VRT dispatch validation to prevent silent dropping of overview_level / on_gpu_failure. |
xrspatial/geotiff/tests/test_open_geotiff_vrt_kwarg_drop_1685.py |
New regression tests covering the new VRT error paths and a non-VRT smoke check for overview_level. |
.claude/sweep-api-consistency-state.csv |
Updates internal sweep tracking notes for the geotiff module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+614
to
+624
| # ``read_vrt`` does not accept ``overview_level`` (the VRT XML | ||
| # references its own source files; overview selection would need | ||
| # to apply to each one). Silently dropping the kwarg was the same | ||
| # class of bug issue #1561 fixed for the dask and GPU dispatchers, | ||
| # so refuse the combination up front rather than handing the | ||
| # caller a full-resolution mosaic with no warning. See issue #1685. | ||
| if overview_level is not None: | ||
| raise ValueError( | ||
| "overview_level is not supported for VRT sources. " | ||
| "VRT references its own source files; pass overview_level " | ||
| "to open_geotiff on a .tif source, or drop the kwarg.") |
Comment on lines
+56
to
+57
| """``overview_level`` plus ``.vrt`` raises ValueError, not a silent drop.""" | ||
| with pytest.raises(ValueError, match="overview_level is not supported"): |
brendancol
added a commit
that referenced
this pull request
May 12, 2026
* Widen write_vrt nodata type hint to accept int (#1684) write_vrt advertised `nodata: float | None` while the sibling writers to_geotiff and write_geotiff_gpu accept "float, int, or None" with no type annotation. Integer sentinels (65535 for uint16, -9999 for int32) round-trip through the rest of the I/O surface; the float-only hint was a static-typing trap, not a runtime constraint. Widen to `float | int | None` on the public wrapper and the internal _vrt.write_vrt, and document the surface match in both docstrings. Add a round-trip regression so future drift surfaces. * Update api-consistency sweep state for geotiff v2 (2026-05-12) Three MEDIUM findings filed and fixed: #1683 (bigtiff docstring gap on to_geotiff), #1684 (write_vrt nodata float|None widened to float|int|None), and #1685 (open_geotiff silently dropped overview_level / on_gpu_failure on VRT sources). PRs #1686, #1687, and #1689. cuda-validated.
…#1685) open_geotiff documents overview_level and on_gpu_failure as supported, but the VRT dispatch branch routes through read_vrt, whose signature accepts neither. Callers got full-resolution data (overview_level) or CPU-decoded output (on_gpu_failure) with no warning. Issue xarray-contrib#1561 fixed the same class of silent kwarg drop for the dask and GPU dispatchers; this commit closes the VRT gap by rejecting both combinations up front with the same wording other VRT-incompatible kwargs already use. Add regressions for the new error path and a smoke test that confirms non-VRT sources still accept overview_level.
Addresses Copilot review on PR xarray-contrib#1689. ``overview_level=0`` is documented as "full resolution" (the default), so passing it on a VRT is semantically equivalent to omitting the kwarg and should not raise. The guard now rejects only non-zero overview levels for VRT sources. The regression test now also covers the ``overview_level=0`` case to prevent the guard from regressing back to ``is not None``.
51481d7 to
93cee55
Compare
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
open_geotiffdocumentsoverview_levelandon_gpu_failureas supported, but the VRT dispatch branch routes throughread_vrtwhose signature accepts neither. Callingopen_geotiff('mosaic.vrt', overview_level=2)returned full-resolution data with no warning -- the same silent kwarg-drop class of bug issue geotiff: backend-specific entry points silently drop kwargs of their dispatchers #1561 fixed for the dask and GPU dispatchers.ValueError, mirroring the wording the dispatcher already uses for other VRT-incompatible kwargs (overview_levelson VRT writes,cog=Trueon VRT writes). Add regressions for the new error path plus a smoke test that confirms non-VRT sources still acceptoverview_level.Fixes #1685. Found during the geotiff API consistency sweep (Cat 5, MEDIUM).
Test plan
pytest xrspatial/geotiff/tests/test_open_geotiff_vrt_kwarg_drop_1685.pypytest xrspatial/geotiff/tests/test_polish_1488.py xrspatial/geotiff/tests/test_backend_kwarg_parity_1561.py xrspatial/geotiff/tests/test_gpu_kwarg_rename_1560.py xrspatial/geotiff/tests/test_vrt_backend_coverage_2026_05_11.py(59 tests, all pass)