Repository navigation
fix(ogc): treat a ".." endpoint in a date range as an open bound - #440
Merged
thodson-usgs merged 2 commits intoOct 7, 2026
Merged
thodson-usgs merged 2 commits into
thodson-usgs merged 2 commits into
Conversation
`_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
approved these changes
Oct 7, 2026
thodson-usgs
left a comment
Collaborator
There was a problem hiding this comment.
Thanks! Pushed a small follow-up so the ratings test doesn't depend on the local time zone.
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.
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.
Fixes #439.
_format_api_datesrecognizedNone,NaNand""as an open endpoint of a two-value range, but not"..", the OGC spelling and the form shown in theget_ratingsdocstring (time=["2026-04-29", ".."]). The".."element failed to parse as a date, and a parse failure discards the whole range. Soget_ratingssearched with nodatetimeand returned every rating (59 instead of 44 for the docstring's bounding box from 2026-09-20 on), and the OGC getters sent an emptytime=that the service rejects with HTTP 400 "Invalid datetime format".The fix makes
_is_blankalso accept"..", so a".."endpoint renders as an open bound just likeNone.[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_datesdocstring now lists".."as an accepted open bound. No getter signature changes.Validation:
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_timeandtest_get_ratings_keeps_a_dotdot_open_bound_in_timeassert 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.get_ratings(bbox=..., time=["2026-09-20", ".."])now returns 44 features (same as the string interval), andget_daily(..., time=["2026-09-01", ".."])returns 36 rows instead of HTTP 400.