Skip to content

Bug: CLI crashes on corrupted or empty config file #60

Description

@Tanishkkkkk

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

  1. Clear or write invalid text to ~/.clutch/config.json.
  2. Run any Clutch CLI command (e.g. clutch whoami).
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions