fix(cli): handle config auth failures without traceback spam by LarytheLord · Pull Request #1080 · mlco2/codecarbon

Summary

Fixes noisy CLI behavior in codecarbon config when an existing login token is expired/invalid.

Previously, show_config() called get_access_token() before entering its try block, so auth/refresh errors escaped and triggered a long traceback. This made the config wizard hard to use for simple re-auth flows.

This PR:

  • moves API/token validation inside the guarded block in show_config()
  • replaces exception re-raise with a concise warning message
  • keeps the wizard flow running so users can continue local config setup

Fixes #855.

Tests

  • Added test_show_config_handles_access_token_errors in tests/cli/test_cli_main.py.
  • Local validation:
    • uv run pytest tests/cli/test_cli_main.py -k "show_config_handles_access_token_errors or test_api_get_calls_api_and_prints"
    • uv run ruff check codecarbon/cli/main.py tests/cli/test_cli_main.py