Skip to content

fix(wqp): send a boolean as yes or no - #477

Merged
thodson-usgs merged 2 commits into
DOI-USGS:mainfrom
thodson-usgs:fix/wqp-boolean-yes-no
Nov 30, 2026
Merged

thodson-usgs merged 2 commits into
DOI-USGS:mainfrom
thodson-usgs:fix/wqp-boolean-yes-no

Conversation

@thodson-usgs

Copy link
Copy Markdown
Collaborator

Follow-up to #473.

Summary

#473 sends numbers and booleans that were dropped before. A boolean reaches a wqp request as true or false, which the legacy /data/ interface rejects with HTTP 400. So wqp.what_sites(sorted=False) now fails, where before #473 the value was dropped and the call worked. Both interfaces accept yes and no.

 _query_wqp(service, legacy, **kwargs)
+  payload = kwargs, with each bool as "yes" or "no"
-  _query_with_retry(url, payload=kwargs, ...)
+  _query_with_retry(url, payload=payload, ...)

The metadata still records the arguments as passed. The NEWS entry for #473 is corrected in place, since it is unreleased.

Evidence

  • Before: legacy /data/Station/search?...&sorted=false and zip=true return HTTP 400.
    After: sorted=no and zip=yes return 200. Live, what_sites(sorted=False) returns rows on the legacy and WQX3 interfaces, and what_sites(lat=43.09, long=-89.4, within=5) returns 708 rows.
  • test_what_sites_sends_numbers_and_booleans_as_wqp_spells_them, run with legacy=True and legacy=False, asserts lat=44.2, within=2.5 and sorted=no in the request. tests/wqp_test.py and tests/utils_test.py pass (102 tests), as do mypy and the pre-commit hooks.

Merge Danger

Door: two-way

Blast Radius: small

A boolean passed to a wqp getter is sent as yes or no. utils.query() keeps #473's true and false.

🤖 Generated with Claude Code

Since DOI-USGS#473, a boolean passed to a wqp getter reaches the request as
true/false. The legacy /data/ interface rejects that with HTTP 400, so
wqp.what_sites(sorted=False) now fails where it used to drop the value.
Both interfaces accept yes/no (checked live: sorted=no and zip=yes return
200 on legacy, sorted=false and zip=true return 400).

The NEWS entry for DOI-USGS#473 is corrected in place, since it is unreleased: it
names the yes/no form and notes that other non-list values are now sent
as str().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thodson-usgs thodson-usgs added the v1 Non-breaking: can merge for the next 1.x release label Nov 24, 2026
NEWS.md: kept main's 11/21 get_ratings entry and this branch's reworded 11/20 entry (yes/no boolean).
@thodson-usgs
thodson-usgs merged commit 67ff6f1 into DOI-USGS:main Nov 30, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Non-breaking: can merge for the next 1.x release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant