henry3260 commented on code in PR #60258:
URL: https://github.com/apache/airflow/pull/60258#discussion_r2725799272
##########
shared/logging/tests/logging/test_percent_formatter.py:
##########
@@ -29,3 +29,21 @@ def test_no_callsite(self):
formatted = fmter(mock.Mock(name="Logger"), "info", {"event": "our
msg"})
assert formatted == "(unknown file):0 our msg"
+
+ def test_percent_formatter_handles_none_values(self):
+ """Test that PercentFormatRender handles None values gracefully."""
+ fmter = PercentFormatRender("%(filename)s:%(lineno)d %(message)s")
+
+ # Mock logger and event_dict with None values
+ logger = mock.Mock(name="Logger")
+ event_dict = {
+ "event": "test message",
+ "filename": None,
+ "lineno": None,
+ }
Review Comment:
> Don't trust me on just reading the code either mind you -- see if you can
replicate the behaviour and see if my proposed change still works
Sorry for the late update. In our original implementation, we use `return
self.event.get("lineno", 0)` as shown in the following case
- If the event lacks lineno: return 0
- If the event contains lineno and lineno is an int: return int
- If the event contains lineno and lineno is None: return None
So I think we can confirm that this bug is caused by `("lineno": None)`
--
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]