From cc3335c55e29a41905003180bbbf04968daa1a9b Mon Sep 17 00:00:00 2001 From: Ankur Shrivastava Date: Mon, 4 May 2026 19:17:29 +0800 Subject: [PATCH 1/2] fix(notifier): migrate Sentry Event.Extra to Contexts for sentry-go v0.46 sentry-go v0.46 removed Event.Extra. Move the extra map to event.Contexts["extra"] (Context is a map[string]interface{} alias, so the payload structure is preserved) and bump the dependency to v0.46.2. --- go.mod | 2 +- go.sum | 4 ++-- notifier/notifier.go | 5 ++++- notifier/notifier_sentry_test.go | 8 ++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index abca013..6c7abe6 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.25.9 require ( github.com/airbrake/gobrake/v5 v5.6.2 - github.com/getsentry/sentry-go v0.43.0 + github.com/getsentry/sentry-go v0.46.2 github.com/go-coldbrew/log v0.3.0 github.com/go-coldbrew/options v0.3.0 github.com/google/uuid v1.6.0 diff --git a/go.sum b/go.sum index 27c2b99..1c52a21 100644 --- a/go.sum +++ b/go.sum @@ -215,8 +215,8 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= -github.com/getsentry/sentry-go v0.43.0 h1:XbXLpFicpo8HmBDaInk7dum18G9KSLcjZiyUKS+hLW4= -github.com/getsentry/sentry-go v0.43.0/go.mod h1:XDotiNZbgf5U8bPDUAfvcFmOnMQQceESxyKaObSssW0= +github.com/getsentry/sentry-go v0.46.2 h1:1jhYwrKGa3sIpo/y5iDNXS5wDoT7I1KNzMHrnK6ojns= +github.com/getsentry/sentry-go v0.46.2/go.mod h1:evVbw2qotNUdYG8KxXbAdjOQWWvWIwKxpjdZZIvcIPw= github.com/ghostiam/protogetter v0.3.20 h1:oW7OPFit2FxZOpmMRPP9FffU4uUpfeE/rEdE1f+MzD0= github.com/ghostiam/protogetter v0.3.20/go.mod h1:FjIu5Yfs6FT391m+Fjp3fbAYJ6rkL/J6ySpZBfnODuI= github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c= diff --git a/notifier/notifier.go b/notifier/notifier.go index fa50165..4f95be7 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -295,7 +295,6 @@ func buildSentryEvent(err errors.ErrorExt, level string, extra map[string]interf Level: sentryLevel, Environment: sentryEnvironment, Release: sentryRelease, - Extra: extra, Exception: []sentry.Exception{ { Type: reflect.TypeOf(err).String(), @@ -305,6 +304,10 @@ func buildSentryEvent(err errors.ErrorExt, level string, extra map[string]interf }, } + if len(extra) > 0 { + event.Contexts = map[string]sentry.Context{"extra": extra} + } + if len(tagData) > 0 { tags := make(map[string]string) for _, t := range tagData { diff --git a/notifier/notifier_sentry_test.go b/notifier/notifier_sentry_test.go index 41d1af2..2d3c6b1 100644 --- a/notifier/notifier_sentry_test.go +++ b/notifier/notifier_sentry_test.go @@ -179,8 +179,8 @@ func TestSentryExtra(t *testing.T) { if event == nil { t.Fatal("expected captured event") } - if len(event.Extra) == 0 { - t.Error("expected non-empty Extra on event") + if len(event.Contexts["extra"]) == 0 { + t.Error("expected non-empty extra context on event") } } @@ -226,8 +226,8 @@ func TestBuildSentryEvent(t *testing.T) { if event.Message != "build event test" { t.Errorf("expected message 'build event test', got %v", event.Message) } - if event.Extra["key"] != "value" { - t.Errorf("expected extra key=value, got %v", event.Extra["key"]) + if event.Contexts["extra"]["key"] != "value" { + t.Errorf("expected extra key=value, got %v", event.Contexts["extra"]["key"]) } if event.Tags["tag1"] != "val1" { t.Errorf("expected tag tag1=val1, got %v", event.Tags["tag1"]) From b4da9136f7e3c32ea43ad859e803133ecf218d0d Mon Sep 17 00:00:00 2001 From: Ankur Shrivastava Date: Mon, 4 May 2026 20:22:04 +0800 Subject: [PATCH 2/2] fix(notifier): preserve existing Contexts when adding extra Initialize event.Contexts lazily and assign the "extra" key, instead of replacing the whole map, so future contexts added before this point aren't clobbered. --- notifier/notifier.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/notifier/notifier.go b/notifier/notifier.go index 4f95be7..732999b 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -305,7 +305,10 @@ func buildSentryEvent(err errors.ErrorExt, level string, extra map[string]interf } if len(extra) > 0 { - event.Contexts = map[string]sentry.Context{"extra": extra} + if event.Contexts == nil { + event.Contexts = make(map[string]sentry.Context) + } + event.Contexts["extra"] = extra } if len(tagData) > 0 {