Skip to content

VRT source-read except Exception should narrow to I/O and parse errors #1670

@brendancol

Description

@brendancol

Describe the bug

xrspatial/geotiff/_vrt.py:353-375 wraps each source read in except Exception. Strict mode (XRSPATIAL_GEOTIFF_STRICT=1, from #1662) re-raises, but the default warns and continues for any exception subclass, including RuntimeError, MemoryError, and anything thrown by code paths that were not envisioned when the catch was written.

The intent is "the source file is unreadable, fall back to fill values." The implementation is "swallow everything the read can throw, including bugs."

Expected behavior

A RuntimeError("synthetic") raised from a stub inside read_to_array should propagate out of read_vrt, not warn-and-continue.

Suggested fix

Replace except Exception with except (OSError, ValueError, struct.error) (or whatever subset matches the documented recoverable error set for read_to_array). Keep the strict-mode raise and the existing warning text.

Add a test that monkeypatches read_to_array to raise RuntimeError and asserts read_vrt propagates rather than warns.

Additional context

Reported during a code review of the geotiff module. Related to the strict-mode work in #1662 / commit 033b6a2.

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