Repository navigation
fix(ogc): raise on an unreadable date bound instead of dropping the filter - #441
Merged
thodson-usgs merged 1 commit intoOct 8, 2026
Conversation
…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
force-pushed
the
fix/raise-on-unparseable-date-bound
branch
from
October 8, 2026 14:31
17708b5 to
cc5c69b
Compare
thodson-usgs
marked this pull request as ready for review
October 8, 2026 14:31
This was referenced Oct 9, 2026
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
Follow-up to #440.
_format_api_datesreturnedNonewhen any non-blank element of a date argument matched no supported format, and both callers readNoneas "no date filter":waterdata.get_ratings()sent the STAC search with nodatetimeand silently returned every rating.time=, and the service answered HTTP 400 "Invalid datetime format", naming no argument.#440 fixed one input that took this path (
".."). Any other unreadable value ("2024-13-45","Jan 1 2024",["2024-01-01", "tomorrow"]) still did.Changes
ogc/dates.py:_format_oneraisesValueErrorfor a non-blank element it can't parse. The message names the caller's argument (name=) and the value, and gives accepted forms, includingNonefor an open end. A range whose ends are all open still returnsNone(no filter). Returns/Raises/Notes updated.time/begin/end/last_modifiedexample blocks, plusget_ratingstimeandngwmn.get_water_leveldatetime, now show the two-value list form withNonefor an open end. Until now that form was documented only in the private helper.ValueError. Forget_ratings, a silently unfiltered result becomes an error.Testing
test_format_api_dates_rejects_an_unreadable_bound(single, unsupported format,"Apr", range start/end),test_get_daily_rejects_an_unreadable_time_before_any_request, andtest_get_ratings_rejects_an_unreadable_time_before_any_request. The two getter tests also assert that no request is sent."Apr"case intest_format_api_datespinned the oldNone. I moved it to the rejection test, where it still checks that"Apr"isn't mistaken for a duration.TZ=UTCandTZ=America/Chicago. Branch coverage is 99.02%.ruff check,ruff format --check,mypy,lint-imports,xenon,complexipy: pass.get_continuous(time="2024-13-45"),get_daily(last_modified=["bad", None]), andngwmn.get_water_level(datetime=[..., "nope"])each raise with the argument named.Not in scope (already true on main)
/is sent unchanged, sotime="garbage/.."still reaches the service unvalidated. Validating each side would need to allow ISO 8601start/durationintervals.pd.Timestamp,datetime) fail withAttributeError/TypeErrorinstead of aValueErrorthat names the argument.