Skip to content

Fix get_reference_table: propagate limit to query args#248

Merged
thodson-usgs merged 4 commits intoDOI-USGS:mainfrom
thodson-usgs:fix/reference-table-limit
May 4, 2026
Merged

Fix get_reference_table: propagate limit to query args#248
thodson-usgs merged 4 commits intoDOI-USGS:mainfrom
thodson-usgs:fix/reference-table-limit

Conversation

@thodson-usgs
Copy link
Copy Markdown
Collaborator

@thodson-usgs thodson-usgs commented May 3, 2026

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

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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 limit into the request args passed to get_ogc_data.
  • Copy the optional query dict before augmentation to avoid mutating caller input.
  • Add a regression test that inspects the outgoing request and verifies limit=42 is 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
thodson-usgs and others added 3 commits May 4, 2026 10:07
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>
@thodson-usgs thodson-usgs marked this pull request as ready for review May 4, 2026 17:00
@thodson-usgs thodson-usgs merged commit aa399be into DOI-USGS:main May 4, 2026
8 checks passed
@thodson-usgs thodson-usgs deleted the fix/reference-table-limit branch May 4, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants