dheerajturaga commented on code in PR #61042:
URL: https://github.com/apache/airflow/pull/61042#discussion_r2748275340
##########
airflow-ctl/src/airflowctl/api/client.py:
##########
@@ -168,7 +168,39 @@ def load(self) -> Credentials:
debug_credentials = json.load(df)
self.api_token =
debug_credentials.get(f"api_token_{self.api_environment}")
else:
- self.api_token = keyring.get_password("airflowctl",
f"api_token_{self.api_environment}")
+ try:
+ self.api_token = keyring.get_password(
+ "airflowctl", f"api_token_{self.api_environment}"
+ )
+ except ValueError as e:
+ # Incorrect keyring password
+ if self.client_kind == ClientKind.AUTH:
+ # For AUTH kind, log warning and continue (user is
logging in)
+ log.warning(
+ "Could not access keyring for environment %s:
%s", self.api_environment, e
+ )
+ self.api_token = None
+ else:
+ # For CLI kind, provide helpful error and raise
+ error_msg = (
+ f"Failed to access system keyring for
environment '{self.api_environment}'. "
+ f"This usually means an incorrect keyring
password was entered.\n"
+ f"To fix this:\n"
+ f" 1. Ensure your system keyring password is
correct\n"
+ f" 2. Or use AIRFLOW_CLI_DEBUG_MODE=true to
bypass keyring\n"
+ f" 3. Or run 'airflowctl auth login' to
re-authenticate"
+ )
+ raise
AirflowCtlCredentialNotFoundException(error_msg) from e
Review Comment:
Done!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]