henry3260 commented on code in PR #73820:
URL: https://github.com/apache/airflow/pull/73820#discussion_r4367451080


##########
go-sdk/pkg/execution/logger_test.go:
##########
@@ -357,6 +358,34 @@ func TestSocketLogHandlerStandardFieldsOverrideAttrs(t 
*testing.T) {
        assert.Equal(t, "example", entry["logger"])
 }
 
+func TestSocketLogHandlerEventAndTimestampOverrideAttrs(t *testing.T) {
+       for _, tt := range []struct {
+               key string
+               val any
+       }{
+               {key: "event", val: "user value"},
+               {key: "timestamp", val: 12345},
+       } {
+               t.Run(tt.key, func(t *testing.T) {
+                       var buf bytes.Buffer
+                       handler := NewSocketLogHandler(&buf, slog.LevelDebug)
+                       logger := slog.New(handler).With(tt.key, tt.val)

Review Comment:
   > > Python doesn't even allow this collision , structlog raises TypeError 
for logger.info("msg", event="x").
   > 
   > I think we should follow the Python side behavior to reject the `event` 
and `timestamp` field being set.
   
   In Python the `TypeError` is fail-fast in the caller, but in Go the only way 
to reject is a panic, which would fail in production instead , so it's not 
really the same case. (Returning an error from `Handle` doesn't work either: 
slog
   discards it, `_ = l.Handler().Handle(ctx, r)`, so the whole line is lost.)
   
   Also Python doesn't reject `timestamp` the supervisor moves a bad value to 
`invalid_timestamp` and keeps going.
   
   So should we rename the field when the user sets a reserved one, the logrus 
way?
   `event` would become `fields.event` and nothing gets dropped.



-- 
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]

Reply via email to