fix(waterdata): numpy array / Series numeric params leaked their repr into the query#308
Draft
thodson-usgs wants to merge 1 commit into
Draft
Conversation
…r()-ing them A numeric (_NO_NORMALIZE_PARAMS) param — water_year, year, month, day, thresholds, … — passed as a numpy array or pandas Series fell into the `args[k] = v` passthrough in _get_args without being materialized to a list. Downstream, the GET comma-join and the chunker both test `list`/`tuple`, so an ndarray/Series was neither comma-joined nor chunked: e.g. get_peaks(water_year=np.array([2020, 2021])) produced `water_year=%5B2020+2021%5D` (the array's repr) instead of `water_year=2020,2021`. Plain lists already worked. Split the branch so _NO_NORMALIZE_PARAMS values keep their element types (no string-normalization) but a non-string iterable is still listified. Co-Authored-By: Claude Opus 4.8 (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.
Problem
A numeric param in
_NO_NORMALIZE_PARAMS(water_year,year,month,day,thresholds, …) passed as a numpy array or pandas Series fell into theargs[k] = vpassthrough in_get_argswithout being materialized to a list. Downstream, both the GET comma-join (",".join(...) if isinstance(v, (list, tuple))) and the chunker (_extract_axes) testlist/tuple— so an ndarray/Series was neither comma-joined nor chunked, and its repr leaked into the URL:Fix
Split the branch so
_NO_NORMALIZE_PARAMSvalues keep their element types (no string-normalization — they're numbers) but a non-string iterable is still materialized to alist, so it comma-joins and chunks like a plain list.Verification
Added a regression test (
test_get_args_materializes_numpy_and_series_numeric_params); existing numeric/construct tests pass;ruffclean.🤖 Generated with Claude Code