From d606feaca4e13326ed30f47e6f92ea4712db4c8e Mon Sep 17 00:00:00 2001 From: Ash Berlin-Taylor Date: Tue, 9 May 2023 11:38:45 +0100 Subject: [PATCH] Remove worrying log message about redaction from the OpenLineage plugin The current published plugin calls `_redact_all` directly, so when we added the `max_depth` parameter in 2.6 (precisely so it didn't need to call this private function directly!) we broke that. This change leads to some worrying logs appearing in task logs for anyone with the plugin installed: ``` [2023-05-05, 11:56:17 BST] {utils.py:490} WARNING - Unable to redact []Error was: TypeError: SecretsMasker._redact_all() missing 1 required positional argument: 'max_depth' [2023-05-05, 11:56:17 BST] {utils.py:490} WARNING - Unable to redact []Error was: TypeError: SecretsMasker._redact_all() missing 1 required positional argument: 'max_depth' [2023-05-05, 11:56:17 BST] {utils.py:490} WARNING - Unable to redact NoneError was: TypeError: SecretsMasker._redact_all() missing 1 required positional argument: 'max_depth' ``` This patch makes that previous change backwards compatible for that with no change in behaviour for new code. --- airflow/utils/log/secrets_masker.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/airflow/utils/log/secrets_masker.py b/airflow/utils/log/secrets_masker.py index cac82d0dd12e2..6703139a3bc8e 100644 --- a/airflow/utils/log/secrets_masker.py +++ b/airflow/utils/log/secrets_masker.py @@ -207,7 +207,9 @@ def filter(self, record) -> bool: return True - def _redact_all(self, item: Redactable, depth: int, max_depth: int) -> Redacted: + # Default on `max_depth` is to support versions of the OpenLineage plugin (not the provider) which called + # this function directly. New versions of that provider, and this class itself call it with a value + def _redact_all(self, item: Redactable, depth: int, max_depth: int = MAX_RECURSION_DEPTH) -> Redacted: if depth > max_depth or isinstance(item, str): return "***" if isinstance(item, dict):