Summary
The load_config function parses the local configuration file using json.loads directly. If the config file is empty or corrupted, it throws an uncaught JSONDecodeError, causing all CLI commands to crash.
Steps to Reproduce
- Clear or write invalid text to
~/.clutch/config.json.
- Run any Clutch CLI command (e.g.
clutch whoami).
- The command fails and prints a Python traceback instead of handling the issue gracefully.
Expected vs Actual
- Expected: The CLI handles invalid configuration files gracefully by prompting the user to login or resetting the configuration.
- Actual: The CLI crashes with an unhandled
json.JSONDecodeError.
Screenshot
No screenshot available (CLI config parsing bug).
Suggested Fix
Wrap the json.loads() call in cli/clutch_cli/config.py in a try/except json.JSONDecodeError block and return an empty dictionary {} if parsing fails.
Summary
The
load_configfunction parses the local configuration file usingjson.loadsdirectly. If the config file is empty or corrupted, it throws an uncaughtJSONDecodeError, causing all CLI commands to crash.Steps to Reproduce
~/.clutch/config.json.clutch whoami).Expected vs Actual
json.JSONDecodeError.Screenshot
No screenshot available (CLI config parsing bug).
Suggested Fix
Wrap the
json.loads()call incli/clutch_cli/config.pyin atry/except json.JSONDecodeErrorblock and return an empty dictionary{}if parsing fails.