Skip to content

fix(sdks/python-cli): preserve saved credentials on transport failure during login (#13191) - #13436

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
CreamPle:fix/python-cli-transport-error-login
Sep 10, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
CreamPle:fix/python-cli-transport-error-login

Conversation

@CreamPle

@CreamPle CreamPle commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #13191.

During developer API-key login (omi auth login --api-key ...), candidate verification sends a probe request to verify the credentials. Previously, _do_api_key_login caught all CliError instances and treated them as non-fatal warnings, saving unverified credentials to disk and exiting with code 0, even when transport / connection failures occurred.

This contradicted the documented contract in README.md ("A transport failure leaves saved credentials unchanged") and caused the pre-existing regression test test_transport_failure_during_login_leaves_saved_config_unchanged to fail across Python CLI CI runs on main.

Changes

  1. sdks/python-cli/omi_cli/errors.py: Added TransportError (subclass of ServerError, preserving EXIT_SERVER = 3).
  2. sdks/python-cli/omi_cli/client.py: Raised TransportError on httpx.TransportError (connection refusal, timeouts, network unreachability).
  3. sdks/python-cli/omi_cli/commands/auth.py: Updated _do_api_key_login to reraise (AuthError, TransportError) so candidate credentials are not persisted when connection fails. Recoverable HTTP 503 errors retain the existing warn-and-store behavior.
  4. sdks/python-cli/tests/test_auth_api_key.py: Added companion test for transport timeout during login verification, confirming exit code 3 and unchanged configuration.

Verification

  • Full Python CLI test suite: 339 passed, 0 failed.
  • Regression tests in tests/test_auth_api_key.py: 17 passed, 0 failed.
  • Whitespace and formatting clean (git diff --check HEAD clean, all lines <= 120 chars).

Review in cubic

Failure-Class: none

… during login (BasedHardware#13191)

API-key login previously caught all CliError instances during candidate verification and treated them as non-fatal warnings, proceeding to save unverified credentials and exit 0 even on transport/connection failures.

Distinguish transport failures by introducing TransportError (subclassing ServerError), and reraise (AuthError, TransportError) in _do_api_key_login so candidate keys are not persisted when connection fails. Existing HTTP 503 warn-and-store behavior remains unchanged.

Fixes BasedHardware#13191.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@aryanorastar aryanorastar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transport-error boundary is correct: transport failures now raise TransportError, preserve the existing server exit code, and are re-raised before credentials are saved. Recoverable HTTP errors retain the warn-and-store behavior. The new timeout regression and full Python CLI suite provide appropriate coverage. Approving.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5/5 confidence: stated root cause (transport failures were silently caught as generic CliError, saving unverified creds), closes #13191, scoped diff (31 lines), CI green, adds regression test. Also fixes the pre-existing test_transport_failure_during_login_leaves_saved_config_unchanged regression on main that is collaterally failing CI on unrelated python-cli PRs.

@kodjima33
kodjima33 merged commit 52c847f into BasedHardware:main Sep 10, 2026
35 of 37 checks passed
Maximus657 added a commit to Maximus657/omi that referenced this pull request Sep 19, 2026
Merge upstream main 5f1cf14, including the login transport fix from BasedHardware#13436
Resolve the README conflict by keeping upstream retry guidance
Pin datetime('now', modifier) in the older literal-match fixtures so they
stay inside the default seven-day window regardless of the execution date

Validation on macOS / Python 3.13
- Before the clock fix, all 16 literal-match cases failed with KeyError
- python -m pytest -q -o addopts='': 451 passed, 1 Windows-only test skipped
- Console entry-point smoke against a loopback API and SQLite: passed
- black --check tests/test_local.py: passed
- git diff --check origin/main: passed

Failure-Class: none
Maximus657 added a commit to Maximus657/omi that referenced this pull request Sep 19, 2026
Merge upstream main 5f1cf14, including BasedHardware#13436
Keep both the upstream retry guidance and clear-due-at documentation when
resolving the README conflict

Validation on macOS / Python 3.13
- python -m pytest -q -o addopts='': 452 passed, 1 Windows-only test skipped
- Console entry-point smoke against a loopback API: explicit null PATCH
- git diff --check origin/main: passed

Failure-Class: none
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.

Python CLI API-key login overwrites saved credentials after transport failure

3 participants