Skip to content

fix(ogc): treat a ".." endpoint in a date range as an open bound - #440

Merged
thodson-usgs merged 2 commits into
DOI-USGS:mainfrom
bhaskargurram-ai:fix/dotdot-open-bound-in-date-range
Oct 7, 2026
Merged

thodson-usgs merged 2 commits into
DOI-USGS:mainfrom
bhaskargurram-ai:fix/dotdot-open-bound-in-date-range

Conversation

@bhaskargurram-ai

Copy link
Copy Markdown
Contributor

Fixes #439.

_format_api_dates recognized None, NaN and "" as an open endpoint of a two-value range, but not "..", the OGC spelling and the form shown in the get_ratings docstring (time=["2026-04-29", ".."]). The ".." element failed to parse as a date, and a parse failure discards the whole range. So get_ratings searched with no datetime and returned every rating (59 instead of 44 for the docstring's bounding box from 2026-09-20 on), and the OGC getters sent an empty time= that the service rejects with HTTP 400 "Invalid datetime format".

The fix makes _is_blank also accept "..", so a ".." endpoint renders as an open bound just like None. [start, ".."] now sends the same range as "start/.." and [start, None], and ["..", ".."] is no filter, like [None, None]. There's a NEWS entry, and the _format_api_dates docstring now lists ".." as an accepted open bound. No getter signature changes.

Validation:

  • New cases in tests/waterdata_utils_test.py::test_format_api_dates (start/end/datetime .. endpoints, plus ["..", ".."] as no filter). New public-getter regressions: test_get_daily_keeps_a_dotdot_open_bound_in_time and test_get_ratings_keeps_a_dotdot_open_bound_in_time assert the query actually sent. The five new .. cases fail on main and pass with the fix.
  • coverage run -m pytest tests/ && coverage report: 1246 passed, 1 skipped; branch coverage 98.98% (gate 98.9).
  • ruff check ., ruff format --check ., mypy: clean.
  • Checked by hand against the live services: get_ratings(bbox=..., time=["2026-09-20", ".."]) now returns 44 features (same as the string interval), and get_daily(..., time=["2026-09-01", ".."]) returns 36 rows instead of HTTP 400.

bhaskargurram-ai and others added 2 commits October 7, 2026 19:08
`_format_api_dates` recognized only None, NaN, and "" as an open
endpoint of a two-value range. A ".." endpoint -- the OGC spelling, and
the form the get_ratings docstring shows (`time=["2026-04-29", ".."]`)
-- failed to parse as a date, which discards the whole range:

- get_ratings searched with no `datetime` and returned every rating;
- the OGC getters sent an empty `time=`, which the service rejects with
  HTTP 400 "Invalid datetime format".

".." is now an open bound like None, so `[start, ".."]` sends the same
range as `"start/.."`.

@thodson-usgs thodson-usgs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Pushed a small follow-up so the ratings test doesn't depend on the local time zone.

@thodson-usgs
thodson-usgs merged commit e8a7dc7 into DOI-USGS:main Oct 7, 2026
thodson-usgs added a commit to thodson-usgs/dataretrieval-python that referenced this pull request Oct 8, 2026
…ilter

_format_api_dates returned None when any non-blank element matched no
supported format. Callers treat None as "no date filter": get_ratings sent
its search without datetime and returned every rating, and the OGC getters
sent an empty time= that the service rejected with an HTTP 400 naming no
argument. DOI-USGS#440 fixed one input that hit this path (".."); every other
unreadable value still did.

The helper now raises ValueError naming the caller's argument and the bad
value, with the accepted forms, before any request. This covers time, begin,
end, datetime, last_modified, and the deprecated begin_utc/end_utc. A range
whose ends are all open still means no filter. The getter docstrings now show
the list form with None for an open end, which the new message points to.
thodson-usgs added a commit that referenced this pull request Oct 8, 2026
…ilter (#441)

_format_api_dates returned None when any non-blank element matched no
supported format. Callers treat None as "no date filter": get_ratings sent
its search without datetime and returned every rating, and the OGC getters
sent an empty time= that the service rejected with an HTTP 400 naming no
argument. #440 fixed one input that hit this path (".."); every other
unreadable value still did.

The helper now raises ValueError naming the caller's argument and the bad
value, with the accepted forms, before any request. This covers time, begin,
end, datetime, last_modified, and the deprecated begin_utc/end_utc. A range
whose ends are all open still means no filter. The getter docstrings now show
the list form with None for an open end, which the new message points to.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

".." endpoint in a time list drops the date filter (get_ratings returns every rating; OGC getters send time=)

2 participants