Skip to content

Commit

Permalink
Fix infinite recursion on redact log (#20039)
Browse files Browse the repository at this point in the history
* Fix infinite recursion on redact log

When redact warning log on "unredactable" item is printed, the
log entered an infinite recursion, because the item was attempted
to be redacted again in the log.

This PR converts the item to str() - in the worst case the str
converstion will fail and raise exception - but this will be about
right - but it will not attempt to redact the item again.

Fixes: #19816

* Update airflow/utils/log/secrets_masker.py

(cherry picked from commit f441833)
  • Loading branch information
potiuk authored and jedcunningham committed Dec 7, 2021
1 parent 2f8594a commit 44430b4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions airflow/utils/log/secrets_masker.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,13 @@ def _redact(self, item: "RedactableItem", name: Optional[str], depth: int) -> "R
else:
return item
# I think this should never happen, but it does not hurt to leave it just in case
# Well. It happened (see https://github.com/apache/airflow/issues/19816#issuecomment-983311373)
# but it caused infinite recursion, so we need to cast it to str first.
except Exception as e:
log.warning(
"Unable to redact %r, please report this via <https://github.com/apache/airflow/issues>. "
"Unable to redact %s, please report this via <https://github.com/apache/airflow/issues>. "
"Error was: %s: %s",
item,
repr(item),
type(e).__name__,
str(e),
)
Expand Down

0 comments on commit 44430b4

Please sign in to comment.