Repository navigation
fix(sdks/python-cli): preserve saved credentials on transport failure during login (#13191) - #13436
Conversation
… 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.
aryanorastar
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
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
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
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_logincaught allCliErrorinstances and treated them as non-fatal warnings, saving unverified credentials to disk and exiting with code0, 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 testtest_transport_failure_during_login_leaves_saved_config_unchangedto fail across Python CLI CI runs onmain.Changes
sdks/python-cli/omi_cli/errors.py: AddedTransportError(subclass ofServerError, preservingEXIT_SERVER = 3).sdks/python-cli/omi_cli/client.py: RaisedTransportErroronhttpx.TransportError(connection refusal, timeouts, network unreachability).sdks/python-cli/omi_cli/commands/auth.py: Updated_do_api_key_loginto reraise(AuthError, TransportError)so candidate credentials are not persisted when connection fails. Recoverable HTTP 503 errors retain the existing warn-and-store behavior.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
tests/test_auth_api_key.py: 17 passed, 0 failed.git diff --check HEADclean, all lines <= 120 chars).Failure-Class: none