Commit 7aeacd5
Return latest paginated/chunked response so QuotaExhausted floor sees current quota
The ``multi_value_chunked`` decorator reads ``x-ratelimit-remaining``
from the response returned by ``fetch_once(sub_args)`` to honor its
documented ``QuotaExhausted`` safety floor. That response was two
layers stale:
1. ``_walk_pages`` captured ``initial_response = resp`` before
pagination and returned it, so any sub-request with N > 1 pages
bubbled up only the first page's headers — the loop already kept
overwriting ``resp`` each iteration; we just weren't returning the
latest.
2. ``_combine_chunk_responses`` returned ``responses[0]`` with summed
``elapsed``, so when ``filters.chunked`` fanned out a long
OR-filter into N sub-chunks the outer wrapper only saw the first
sub-chunk's headers.
Composed, the staleness gap per outer chunk was
``inner_chunks × pages_per_inner_chunk − 1`` HTTP requests of quota
consumption the chunker was blind to. For the canonical workload
(chained query, long site list, paginated filter) that gap easily
exceeds the default floor of 50, so the guard never tripped — users
hit ``RuntimeError("429: Too many requests...")`` from
``_raise_for_non_200`` instead of the structured ``QuotaExhausted``
with ``partial_frame``/``completed_chunks`` they were promised.
Fix both layers: ``_walk_pages`` returns the latest ``resp`` (which
the loop was already maintaining), and ``_combine_chunk_responses``
returns ``responses[-1]`` (with ``elapsed`` summed onto it instead
of onto ``responses[0]``). Both changes match
``QuotaExhausted.partial_response``'s docstring ("metadata for the
last successful sub-request"). Same fix applied to the parallel
pagination loop in the stats helper for consistency.
No behavior change for single-page mocked tests (initial == latest).
209 waterdata unit tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a9cf2d7 commit 7aeacd5
2 files changed
Lines changed: 16 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
274 | 279 | | |
275 | 280 | | |
276 | | - | |
| 281 | + | |
277 | 282 | | |
278 | | - | |
279 | | - | |
| 283 | + | |
| 284 | + | |
280 | 285 | | |
281 | 286 | | |
282 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
646 | | - | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
647 | 650 | | |
648 | 651 | | |
649 | 652 | | |
| |||
666 | 669 | | |
667 | 670 | | |
668 | 671 | | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
| |||
697 | 697 | | |
698 | 698 | | |
699 | 699 | | |
700 | | - | |
| 700 | + | |
701 | 701 | | |
702 | 702 | | |
703 | 703 | | |
| |||
1128 | 1128 | | |
1129 | 1129 | | |
1130 | 1130 | | |
1131 | | - | |
1132 | | - | |
1133 | | - | |
1134 | 1131 | | |
1135 | 1132 | | |
1136 | 1133 | | |
| |||
1173 | 1170 | | |
1174 | 1171 | | |
1175 | 1172 | | |
1176 | | - | |
| 1173 | + | |
1177 | 1174 | | |
1178 | 1175 | | |
1179 | 1176 | | |
| |||
0 commit comments