Validate monitoring_location_id format in waterdata functions#229
Draft
thodson-usgs wants to merge 1 commit intoDOI-USGS:mainfrom
Draft
Validate monitoring_location_id format in waterdata functions#229thodson-usgs wants to merge 1 commit intoDOI-USGS:mainfrom
thodson-usgs wants to merge 1 commit intoDOI-USGS:mainfrom
Conversation
Passing an integer (e.g. 5129115) or a bare string without an agency prefix (e.g. "dog") to any waterdata function silently wasted an API call and returned empty data. Now all ten public functions that accept monitoring_location_id raise before touching the network: - TypeError if the value is not a string or list of strings - ValueError if any string doesn't match the 'AGENCY-ID' format (e.g. 'USGS-01646500') Closes DOI-USGS#188. Co-Authored-By: Claude Sonnet 4.6 <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
Closes #188.
Passing an integer or a bare string (without the required
AGENCY-IDprefix) to a waterdata function silently wasted an API call and returned confusing empty results. Now all 10 public functions that acceptmonitoring_location_idraise immediately before any network call:Functions covered:
get_daily,get_continuous,get_monitoring_locations,get_time_series_metadata,get_latest_continuous,get_latest_daily,get_field_measurements,get_stats_por,get_stats_date_range,get_channelValidation rules:
strorlist[str](notint,float, etc.) →TypeError-separator (AGENCY-IDformat) →ValueErrorNoneis allowed (optional parameter)Test plan
None, bare integer, integer in list, missing agency prefix, bare site number, and end-to-endget_dailychecks🤖 Generated with Claude Code