Cwms-cli usgs timeseries does not strip the trailing whitespaces from the Alias when building the station list from "Location Group - USGS Station Number".
If trailing whitespaces are present, the URL that is built will contain "++++" causing it to fail:
2026-08-11 14:14:29;DEBUG;Starting new HTTPS connection (1): waterservices.usgs.gov:443
2026-08-11 14:14:30;DEBUG;https://waterservices.usgs.gov:443 "GET /nwis/iv/?format=json&sites=08330830+++++++%2C09357000+++++++%2C08401450%2C08302500+++++++%2C384048104504901%2C08289000%2C07130000%2C07124410%2C07124400%2C08263500%2C09363500%2C07134990%2C09432000%2C08277470%2C08287000%2C07099238%2C384037104472001%2C07138075%2C07138063%2C08385503%2C07227100%2C08265000%2C07103703%2C383619104520401%2C07138050%2C07137000%2C07226500+++++++&startDT=2026-08-10T14%3A14%3A24.500202&endDT=2026-08-11T16%3A14%3A24.500202&access=3&siteStatus=active HTTP/1.1" 400 503
Unexpected error. Report it at https://github.com/HydrologicEngineeringCenter/cwms-cli/issues/new?template=bug-report.yml
Traceback (most recent call last):
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/requests/models.py", line 976, in json
return complexjson.loads(self.text, **kwargs)
File "/wm/wmsoft/python/v3.9.18-Solaris11.4.86.201.2/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/wm/wmsoft/python/v3.9.18-Solaris11.4.86.201.2/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/wm/wmsoft/python/v3.9.18-Solaris11.4.86.201.2/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/wm/spa/l4cwpa43/.local/bin/cwms-cli", line 6, in <module>
sys.exit(main())
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/cwmscli/__main__.py", line 119, in main
cli(standalone_mode=False)
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/click/core.py", line 1161, in __call__
return self.main(*args, **kwargs)
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/click/core.py", line 1082, in main
rv = self.invoke(ctx)
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/click/core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/click/core.py", line 788, in invoke
return __callback(*args, **kwargs)
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/cwmscli/utils/deps.py", line 111, in wrapper
return func(*args, **kwargs)
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/cwmscli/usgs/__init__.py", line 54, in getusgs_timeseries
getusgs_cda(
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/cwmscli/usgs/getusgs_cda.py", line 88, in getusgs_cda
USGS_data_method = getUSGS_ts(method_sites, startDT, endDT, 3)
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/cwmscli/usgs/getusgs_cda.py", line 272, in getUSGS_ts
r = requests.get(base_url, params=query_dict).json()
File "/wm/spa/l4cwpa43/.local/lib/python3.9/site-packages/requests/models.py", line 980, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
CLI Script
getusgs-timeseries
Describe the bug
Cwms-cli usgs timeseries does not strip the trailing whitespaces from the Alias when building the station list from "Location Group - USGS Station Number".
If trailing whitespaces are present, the URL that is built will contain "++++" causing it to fail:
example:
REDACTED relevant log output
Steps to Reproduce
No response