Skip to content

Commit

Permalink
Fix infinite recursion on redact log
Browse files Browse the repository at this point in the history
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.

Fixws: #19816
  • Loading branch information
Jaroslaw Potiuk authored and potiuk committed Dec 5, 2021
1 parent 2391b19 commit 933c0b1
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 @@ -213,11 +213,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,
item.repr(),
type(e).__name__,
str(e),
)
Expand Down

0 comments on commit 933c0b1

Please sign in to comment.