Fix get_reference_table: propagate limit to query args#248
Merged
thodson-usgs merged 4 commits intoDOI-USGS:mainfrom May 4, 2026
Merged
Fix get_reference_table: propagate limit to query args#248thodson-usgs merged 4 commits intoDOI-USGS:mainfrom
thodson-usgs merged 4 commits intoDOI-USGS:mainfrom
Conversation
The signature accepted and documented a `limit` parameter, but the function never forwarded it into `query_args`, so every call fetched at the schema/server default regardless of what the user requested. Forward `limit` into a copy of the user-supplied `query` dict (so the caller's dict is not mutated) when it is not None. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes dataretrieval.waterdata.get_reference_table so its documented limit argument is actually propagated into the underlying OGC request, aligning the public API with existing behavior in the rest of the Water Data client.
Changes:
- Forward
limitinto the request args passed toget_ogc_data. - Copy the optional
querydict before augmentation to avoid mutating caller input. - Add a regression test that inspects the outgoing request and verifies
limit=42is sent.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
dataretrieval/waterdata/api.py |
Updates get_reference_table to merge limit into the OGC query args before dispatch. |
tests/waterdata_test.py |
Adds a mocked regression test that validates the request query string includes the forwarded limit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1545
to
+1547
| query_args = dict(query) if query else {} | ||
| if limit is not None: | ||
| query_args["limit"] = limit |
Per copilot review on PR DOI-USGS#248. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
`get_reference_table(limit=...)` documents the parameter and accepts it, but never propagates it into the OGC request — `query_args = query or {}` was passed to `get_ogc_data` without merging `limit`. The argument was therefore silently ignored.
This PR merges `limit` into `query_args` before dispatch, copying the caller's `query` dict first so the user's input is not mutated as a side effect.
Test plan
No regression test — the diff is a one-line forwarding fix and any unit test would just re-state it.
🤖 Generated with Claude Code