Skip to content

fix(cli): catch OAuth error in register-webapp - #575

Merged
leoschwarz merged 1 commit into
mainfrom
fix/register-webapp-oauth-error
Aug 7, 2026
Merged

fix(cli): catch OAuth error in register-webapp#575
leoschwarz merged 1 commit into
mainfrom
fix/register-webapp-oauth-error

Conversation

@Caushi

@Caushi Caushi commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • bfabric-cli auth register-webapp crashed with a raw Python traceback when the OAuth session's refresh token was expired/revoked, instead of printing a clean error like the rest of the command.
  • client.auth.password.get_secret_value() (the call that triggers a token refresh) sat outside any try/except, so the BfabricOAuthError raised by credential_provider.py had no local handler and propagated past __main__.py's bare app() call.
  • Wrapped that call in the same try/except pattern already used by its neighbors in this file, so it now prints Error: ... and exits 1.

Test plan

  • Manually confirmed the code path: credential_provider._ensure_token raises BfabricOAuthError (a RuntimeError) on invalid_grant; the new try/except in register_webapp.py catches it and prints a clean message instead of a traceback.
  • Reproduce locally with a stale/revoked refresh token cached for an OAuth env and confirm bfabric-cli auth register-webapp now prints Error: OAuth session expired (...) and exits 1 instead of a traceback.

@leoschwarz

Copy link
Copy Markdown
Member

Thank you. I think error handling in the CLI is a bit weak in general, maybe at some point making use of Cyclopts error handling https://cyclopts.readthedocs.io/en/latest/app_calling.html#exception-handling-and-exiting would make sense.

@leoschwarz
leoschwarz merged commit c6d4307 into main Aug 7, 2026
24 checks passed
@leoschwarz
leoschwarz deleted the fix/register-webapp-oauth-error branch August 7, 2026 07:52
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.

2 participants