Skip to content

fix(cli): warn when auth validation falls back to API#1209

Open
puneetdixit200 wants to merge 1 commit into
mlco2:masterfrom
puneetdixit200:fix/1208-auth-validation-warning
Open

fix(cli): warn when auth validation falls back to API#1209
puneetdixit200 wants to merge 1 commit into
mlco2:masterfrom
puneetdixit200:fix/1208-auth-validation-warning

Conversation

@puneetdixit200
Copy link
Copy Markdown
Contributor

Description

Log a warning when local CLI access-token validation is skipped because the auth server cannot be reached. This preserves the existing offline/flaky-network fallback while making it explicit that token freshness was not proven locally and the API will make the final authorization decision.

Related Issue

Fixes #1208

Motivation and Context

The existing fallback is useful for availability, but silent success makes the path look like a completed local validation. A warning keeps the behavior unchanged while surfacing the caveat from the issue.

How Has This Been Tested?

Red before implementation:

uv run --group dev python -m pytest -q tests/cli/test_cli_auth.py::TestAuthMethods::test_validate_access_token_network_error_returns_true

Green after implementation:

uv run --group dev python -m pytest -q tests/cli/test_cli_auth.py::TestAuthMethods::test_validate_access_token_network_error_returns_true
uv run --group dev python -m pytest -q tests/cli/test_cli_auth.py tests/cli/test_cli.py tests/cli/test_cli_main.py
uv run --group dev black --check codecarbon/cli/auth.py tests/cli/test_cli_auth.py
uv run --group dev ruff check codecarbon/cli/auth.py tests/cli/test_cli_auth.py
git diff HEAD^ --check

Screenshots (if appropriate):

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

AI Usage Disclosure

OpenAI GPT-5 generated the small code/test change and PR text under explicit human-directed issue-fix constraints. I reviewed the touched auth path, preserved existing fallback behavior, and verified the change with the commands listed above.

  • 🟥 AI-vibecoded: You cannot explain the logic. Car analogy : the car drive by itself, you are outside it and just tell it where to go.
  • 🟠 AI-generated: Car analogy : the car drive by itself, you are inside and give instructions.
  • ⭐ AI-assisted. Car analogy : you drive the car, AI help you find your way.
  • ♻️ No AI used. Car analogy : you drive the car.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the docs/how-to/contributing.md document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Log a warning when local CLI access-token validation is skipped because the auth server cannot be reached, while preserving the existing availability fallback.

Fixes mlco2#1208
@puneetdixit200 puneetdixit200 requested a review from a team as a code owner May 20, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI auth falls back to API on auth-server network errors

1 participant