-
Notifications
You must be signed in to change notification settings - Fork 3
[TD-016] CLI date argument validation happens late #13
Copy link
Copy link
Open
Labels
Description
Description
Date format validation happens implicitly when passed to APIs, leading to cryptic error messages late in execution.
Location
- File:
cost_collect.pyaround line 716-720
Impact
- Poor user experience
- Wasted time waiting for collection to fail
- Cryptic error messages from downstream APIs
Suggested Fix
Add early validation in argument parser:
def valid_date(date_string: str) -> str:
"""Validate date format YYYY-MM-DD."""
try:
datetime.strptime(date_string, '%Y-%m-%d')
return date_string
except ValueError:
raise argparse.ArgumentTypeError(
f"Invalid date format: '{date_string}'. Expected YYYY-MM-DD"
)
parser.add_argument('--start-date', type=valid_date, ...)
parser.add_argument('--end-date', type=valid_date, ...)Priority
Low
Source
TECH_DEBT.md - TD-016
Reactions are currently unavailable