geopython / geopython/pygeoapi

Rasterio Coverage Requests Fail for GCS/VSI Paths Without Bbox Parameter

Open
#2,402 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
624
Forks
326
Avg merge
8h 25m
Merged PRs (30d)
2

Description

# Bug Report: Rasterio Coverage Requests Fail for GCS/VSI Paths Without Bbox Parameter

## Description

Coverage requests to rasterio providers using GDAL Virtual File System (VSI) paths (e.g., `/vsigs/` for GCS) succeed when a `bbox` parameter is included, but fail with `FileNotFoundError` when no `bbox` is specified.

The root cause is an early-return optimization in pygeoapi's rasterio provider that bypasses rasterio/GDAL for native format requests with no bands, subsets, or bbox (i.e a plain {collectionsid}/coverage?f=GTiff type call). This shortcut delegates to `util.read_data()`, which only recognizes `http://` and `s3://` as remote paths and treats all other paths (including `/vsigs/`) as local file paths. GDAL VSI paths cannot be opened with `Path.open("rb")`, causing the failure.

Requests *with* a bbox parameter continue through the full rasterio/GDAL code path, which correctly handles VSI paths, so they succeed.

## Steps to Reproduce

1. Configure a pygeoapi coverage collection with a rasterio coverage provider pointing to a GCS object via `/vsigs/` path (e.g., `/vsigs/bucket-name/file.tif`)
2. Ensure `GOOGLE_APPLICATION_CREDENTIALS` is set and valid with GCS read permissions
3. Request the coverage without a bbox parameter: GET /collections/raster_collection/coverage?format=tif

4. Observe error:FileNotFoundError: [Errno 2] No such file or directory: '/vsigs/bucket-name/file.tif'

5. Request the same coverage *with* a bbox parameter: GET /collections/raster_collection/coverage?bbox=3.0,56.5,32.0,71.5&format=tif

6. Observe the request succeeds and returns the raster data

## Expected Behavior

Coverage requests should handle GDAL VSI paths correctly regardless of whether optional parameters like `bbox` are present. Both requests should succeed when the credentials and path are valid.

## Environment

- **pygeoapi version:** 0.24.0
- **Python version:** 3.11 (in geopython/pygeoapi:0.24.0 base image)
- **Operating System:** Windows 10/11 (Docker Desktop)
- **GDAL/rasterio version:** Latest in base image (rasterio 1.3.x+)
- **Storage backend:** Google Cloud Storage (GCS) via `/vsigs/` VSI path

Contributor guide

Open the contributing guide

Research direction

Start with the rasterio coverage provider's early-return path and util.read_data(), then reproduce the coverage request with a /vsigs/ path both with and without bbox. Check the existing rasterio/provider tests for the closest coverage request cases. Done means native-format requests without bbox handle VSI paths and the existing bbox behavior remains successful.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend, data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.