Andrushika commented on code in PR #76287:
URL: https://github.com/apache/airflow/pull/76287#discussion_r4463488453


##########
airflow-ctl/src/airflowctl/api/client.py:
##########
@@ -241,15 +241,29 @@ def save(self, skip_keyring: bool = False):
 
         Skip saving the token to keyring if skip_keyring is True, in this case,
         only the config file with the API URL is created.
+
+        The token already stored in keyring for the environment is removed 
first,
+        so a failure later on cannot leave it paired with the new API URL.
         """
         default_config_dir = os.environ.get("AIRFLOW_HOME", 
os.path.expanduser("~/airflow"))
         os.makedirs(default_config_dir, exist_ok=True)
         config_path = _safe_path_under_airflow_home(default_config_dir, 
self.input_cli_config_file)
+        debug_mode = os.getenv("AIRFLOW_CLI_DEBUG_MODE") == "true"
+        if not debug_mode:
+            try:
+                keyring.delete_password("airflowctl", 
self.token_key_for_environment(self.api_environment))
+            except (PasswordDeleteError, NoKeyringError):
+                pass
+            except KeyringError as e:

Review Comment:
   Thanks, I changed the approach in b07421a8b8, so `--skip-keyring` no longer 
touches the keyring.



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