fix(cli): handle config auth failures without traceback spam#1080
Merged
SaboniAmine merged 1 commit intomlco2:masterfrom Feb 26, 2026
Merged
Conversation
SaboniAmine
approved these changes
Feb 26, 2026
Member
SaboniAmine
left a comment
There was a problem hiding this comment.
LGTM, thanks for your contribution!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1080 +/- ##
==========================================
+ Coverage 78.14% 78.19% +0.05%
==========================================
Files 38 38
Lines 3637 3637
==========================================
+ Hits 2842 2844 +2
+ Misses 795 793 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes noisy CLI behavior in
codecarbon configwhen an existing login token is expired/invalid.Previously,
show_config()calledget_access_token()before entering itstryblock, 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:
show_config()Fixes #855.
Tests
test_show_config_handles_access_token_errorsintests/cli/test_cli_main.py.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