Skip to content

Commit 50aa8ba

Browse files
pieternclaude
andauthored
Remove nil context fallback from libs/log (#4656)
## Summary - Remove the `nil` context fallback from functions in `libs/log` - Passing a nil context is an error; callers should always pass a valid context From https://pkg.go.dev/context: > Do not pass a nil [Context](https://pkg.go.dev/context#Context), even if a function permits it. Pass [context.TODO](https://pkg.go.dev/context#TODO) if you are unsure about which Context to use. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 47d9694 commit 50aa8ba

File tree

2 files changed

+0
-6
lines changed

2 files changed

+0
-6
lines changed

libs/log/logger.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ func log(ctx context.Context, logger *slog.Logger, level slog.Level, msg string)
2424
// skip [runtime.Callers, this function, this function's caller].
2525
runtime.Callers(3, pcs[:])
2626
r := slog.NewRecord(time.Now(), level, msg, pcs[0])
27-
if ctx == nil {
28-
ctx = context.Background()
29-
}
3027
_ = logger.Handler().Handle(ctx, r)
3128
}
3229

libs/log/sdk.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ func (s slogAdapter) log(ctx context.Context, logger *slog.Logger, level slog.Le
3737
runtime.Callers(4, pcs[:])
3838
r := slog.NewRecord(time.Now(), level, msg, pcs[0])
3939
r.AddAttrs(slog.Bool("sdk", true))
40-
if ctx == nil {
41-
ctx = context.Background()
42-
}
4340
_ = logger.Handler().Handle(ctx, r)
4441
}
4542

0 commit comments

Comments
 (0)