-
Notifications
You must be signed in to change notification settings - Fork 3
[CC-005] Missing date validation in cost_collect.py #17
Copy link
Copy link
Open
Labels
Description
Description
Date parameters are not validated early, leading to cryptic API errors when invalid dates are provided.
Location
- File:
cost_collect.py- CLI argument handling
Impact
- Poor user experience
- Time wasted on failed collection
- Cryptic error messages from cloud APIs
Note
This overlaps with TD-016 but is specific to cost_collect.py.
Suggested Fix
Add validation in argument parser:
def valid_date(s: str) -> datetime:
try:
return datetime.strptime(s, '%Y-%m-%d')
except ValueError:
raise argparse.ArgumentTypeError(f"Invalid date: {s}. Use YYYY-MM-DD")
parser.add_argument('--start-date', type=valid_date)
parser.add_argument('--end-date', type=valid_date)Also validate that start_date < end_date and range is not too large.
Priority
Medium
Source
cost_collect.py code review - CC-005
Reactions are currently unavailable