Skip to content

Fix airflowctl crash when incorrect keyring password is entered#61042

Merged
dheerajturaga merged 5 commits into
apache:mainfrom
dheerajturaga:bugfix/airflowctl-login-exception
Jan 30, 2026
Merged

Fix airflowctl crash when incorrect keyring password is entered#61042
dheerajturaga merged 5 commits into
apache:mainfrom
dheerajturaga:bugfix/airflowctl-login-exception

Conversation

@dheerajturaga

Copy link
Copy Markdown
Member

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

  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.
Comment thread airflow-ctl/src/airflowctl/api/client.py Outdated

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM with one comment about communicating errors to the users which requires @bugraoz93 input.

@bugraoz93 bugraoz93 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! Thanks!

@dheerajturaga dheerajturaga merged commit 0ede1b2 into apache:main Jan 30, 2026
82 checks passed
@dheerajturaga dheerajturaga deleted the bugfix/airflowctl-login-exception branch January 30, 2026 22:45
morelgeorge pushed a commit to morelgeorge/airflow that referenced this pull request Feb 1, 2026
shashbha14 pushed a commit to shashbha14/airflow that referenced this pull request Feb 2, 2026
jason810496 pushed a commit to abhijeets25012-tech/airflow that referenced this pull request Feb 3, 2026
jhgoebbert pushed a commit to jhgoebbert/airflow_Owen-CH-Leung that referenced this pull request Feb 8, 2026
choo121600 pushed a commit to choo121600/airflow that referenced this pull request Feb 22, 2026
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Mar 4, 2026
Ankurdeewan pushed a commit to Ankurdeewan/airflow that referenced this pull request Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants