dheerajturaga opened a new pull request, #61042:
URL: https://github.com/apache/airflow/pull/61042

   When using an encrypted keyring with airflowctl, entering an incorrect
   keyring password caused an unhandled ValueError exception. This adds
   proper exception handling in Credentials.load() to provide user-friendly
   error messages with actionable steps for recovery. AUTH commands now
   continue gracefully while CLI commands display helpful guidance.
   
   ```
   Please enter password for encrypted keyring:
   Please enter password for encrypted keyring:
   Traceback (most recent call last):
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file.py", line 
186, in _unlock
       ref_pw = self.get_password('keyring-setting', 'password reference')
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file_base.py", 
line 106, in get_password
       password = self.decrypt(password_encrypted, assoc).decode('utf-8')
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file.py", line 
218, in decrypt
       assert plaintext.startswith(self.pw_prefix)
   AssertionError
   
   During handling of the above exception, another exception occurred:
   
   Traceback (most recent call last):
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file_base.py", 
line 106, in get_password
       password = self.decrypt(password_encrypted, assoc).decode('utf-8')
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file.py", line 
216, in decrypt
       cipher = self._create_cipher(self.keyring_key, data['salt'], data['IV'])
     File 
"/usr/python/lib/python3.10/site-packages/jaraco/classes/properties.py", line 
76, in __get__
       return self.fget(obj)
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file.py", line 
99, in keyring_key
       self._unlock()
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file.py", line 
190, in _unlock
       raise ValueError("Incorrect Password")
   ValueError: Incorrect Password
   
   During handling of the above exception, another exception occurred:
   
   Traceback (most recent call last):
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file.py", line 
186, in _unlock
       ref_pw = self.get_password('keyring-setting', 'password reference')
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file_base.py", 
line 106, in get_password
       password = self.decrypt(password_encrypted, assoc).decode('utf-8')
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file.py", line 
218, in decrypt
       assert plaintext.startswith(self.pw_prefix)
   AssertionError
   
   During handling of the above exception, another exception occurred:
   
   Traceback (most recent call last):
     File "/usr/python/bin/airflowctl", line 10, in <module>
       sys.exit(main())
     File "/opt/airflow/airflow-ctl/src/airflowctl/__main__.py", line 34, in 
main
       safe_call_command(args.func, args=args)
     File "/opt/airflow/airflow-ctl/src/airflowctl/ctl/cli_config.py", line 76, 
in safe_call_command
       function(args)
     File "/opt/airflow/airflow-ctl/src/airflowctl/ctl/cli_config.py", line 59, 
in command
       return func(*args, **kwargs)
     File "/opt/airflow/airflow-ctl/src/airflowctl/api/client.py", line 355, in 
wrapper
       with get_client(kind=kind) as api_client:
     File "/usr/python/lib/python3.10/contextlib.py", line 135, in __enter__
       return next(self.gen)
     File "/opt/airflow/airflow-ctl/src/airflowctl/api/client.py", line 323, in 
get_client
       credentials = Credentials(client_kind=kind).load()
     File "/opt/airflow/airflow-ctl/src/airflowctl/api/client.py", line 172, in 
load
       self.api_token = keyring.get_password("airflowctl", 
f"api_token_{self.api_environment}")
     File "/usr/python/lib/python3.10/site-packages/keyring/core.py", line 63, 
in get_password
       return get_keyring().get_password(service_name, username)
     File 
"/usr/python/lib/python3.10/site-packages/keyring/backends/chainer.py", line 
49, in get_password
       password = keyring.get_password(service, username)
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file_base.py", 
line 109, in get_password
       password = self.decrypt(password_encrypted).decode('utf-8')
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file.py", line 
216, in decrypt
       cipher = self._create_cipher(self.keyring_key, data['salt'], data['IV'])
     File 
"/usr/python/lib/python3.10/site-packages/jaraco/classes/properties.py", line 
76, in __get__
       return self.fget(obj)
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file.py", line 
99, in keyring_key
       self._unlock()
     File "/usr/python/lib/python3.10/site-packages/keyrings/alt/file.py", line 
190, in _unlock
       raise ValueError("Incorrect Password")
   ValueError: Incorrect Password
   ```


-- 
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]

Reply via email to