You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "YoannAbriel (via GitHub)" <gi...@apache.org> on 2026/04/04 09:12:00 UTC

Re: [PR] fix(api): handle undecryptable connection fields after Fernet key change [airflow]

YoannAbriel commented on code in PR #63351:
URL: https://github.com/apache/airflow/pull/63351#discussion_r3035373348


##########
airflow-core/src/airflow/models/connection.py:
##########
@@ -360,7 +360,15 @@ def get_password(self) -> str | None:
                     f"Can't decrypt encrypted password for login={self.login}  "
                     f"FERNET_KEY configuration is missing"
                 )
-            return fernet.decrypt(bytes(self._password, "utf-8")).decode()
+            try:
+                return fernet.decrypt(bytes(self._password, "utf-8")).decode()
+            except Exception:
+                log.warning(
+                    "Failed to decrypt password for connection %s. "
+                    "This may happen after migrating with a different Fernet key.",
+                    self.conn_id,
+                )
+                return None

Review Comment:
   It surfaces the actual error instead of a generic 500 — helps operators debug Fernet key rotations without digging through logs.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org