You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add get_stats_data failure tests and tighten PR #273
Follow-up cleanups on top of the silent-truncation fix:
- New tests for the get_stats_data parallel pagination loop, mirroring
the _walk_pages ConnectionError + 5xx pair (closes coverage gap from
the prior commits).
- Lift the hard-coded logger-name string to a module-level _LOGGER_NAME
constant derived from the utils module's __name__ (self-syncing).
- logger.error → logger.exception in both pagination except clauses so
the traceback is automatically attached to the log record.
- _raise_for_non_200 docstring: drop the historical bug narration, add
a one-line note distinguishing it from Response.raise_for_status
(we route through _error_body for USGS-API-aware messages).
- Drop the inconsistent "resp may be stale" comment; the `as e` and
variable naming already convey intent, and get_stats_data already
sidesteps it by logging `url` instead of `resp.url`.
- _run_get_stats_data_with_failure: make monkeypatch a required arg
(both callers pass it), and swap the lambda for MagicMock so future
signature drift in _handle_stats_nesting isn't silently masked.
- Tighten test docstrings that narrated the PR/bug.
- Extract _error_log_messages(caplog) helper (used 4 times).
- Lift the conditional links ternary out of the dict literal in _resp_ok.
- NEWS.md: bump date to today.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: NEWS.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
**05/08/2026:** Fixed two latent bugs in the paginated `waterdata` request loop (`_walk_pages` and `get_stats_data`). Previously, when `requests.Session.request(...)` itself raised mid-pagination (network error, timeout), the except block called `_error_body()` on the *prior page's* response, so the logged "error" described the wrong request and could itself crash on non-JSON bodies. Separately, no status-code check was performed on subsequent paginated responses, so a 5xx body that didn't include `numberReturned` was silently treated as an empty page — pagination quietly stopped and the user got truncated data with no error logged. The loop now status-checks each page like the initial request and reports the actual exception. The "best-effort" behavior (return whatever pages were collected) is preserved.
1
+
**05/14/2026:** Fixed two latent bugs in the paginated `waterdata` request loop (`_walk_pages` and `get_stats_data`). Previously, when `requests.Session.request(...)` itself raised mid-pagination (network error, timeout), the except block called `_error_body()` on the *prior page's* response, so the logged "error" described the wrong request and could itself crash on non-JSON bodies. Separately, no status-code check was performed on subsequent paginated responses, so a 5xx body that didn't include `numberReturned` was silently treated as an empty page — pagination quietly stopped and the user got truncated data with no error logged. The loop now status-checks each page like the initial request and reports the actual exception. The "best-effort" behavior (return whatever pages were collected) is preserved.
2
2
3
3
**05/06/2026:** Each remaining active function in `dataretrieval.nwis` now emits a per-function `DeprecationWarning` naming the `waterdata` replacement to migrate to (visible the first time users call each getter). The `nwis` module is scheduled for removal on or after **2027-05-06**.
0 commit comments