Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Guard against a nil client when setting the SDK identifer #715

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion echo/sentryecho.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
hub = sentry.CurrentHub().Clone()
}

hub.Client().SetSDKIdentifier(sdkIdentifier)
if client := hub.Client(); client != nil {
client.SetSDKIdentifier(sdkIdentifier)
}

Check warning on line 58 in echo/sentryecho.go

View check run for this annotation

Codecov / codecov/patch

echo/sentryecho.go#L56-L58

Added lines #L56 - L58 were not covered by tests

hub.Scope().SetRequest(ctx.Request())
ctx.Set(valuesKey, hub)
Expand Down
4 changes: 3 additions & 1 deletion fasthttp/sentryfasthttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ func (h *Handler) Handle(handler fasthttp.RequestHandler) fasthttp.RequestHandle
// context.Context but requires string keys.
hub := sentry.CurrentHub().Clone()

hub.Client().SetSDKIdentifier(sdkIdentifier)
if client := hub.Client(); client != nil {
client.SetSDKIdentifier(sdkIdentifier)
}

scope := hub.Scope()
scope.SetRequest(convert(ctx))
Expand Down
4 changes: 3 additions & 1 deletion gin/sentrygin.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func (h *handler) handle(c *gin.Context) {
ctx = sentry.SetHubOnContext(ctx, hub)
}

hub.Client().SetSDKIdentifier(sdkIdentifier)
if client := hub.Client(); client != nil {
client.SetSDKIdentifier(sdkIdentifier)
}

var transactionName string
var transactionSource sentry.TransactionSource
Expand Down
4 changes: 3 additions & 1 deletion http/sentryhttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ func (h *Handler) handle(handler http.Handler) http.HandlerFunc {
ctx = sentry.SetHubOnContext(ctx, hub)
}

hub.Client().SetSDKIdentifier(sdkIdentifier)
if client := hub.Client(); client != nil {
client.SetSDKIdentifier(sdkIdentifier)
}

options := []sentry.SpanOption{
sentry.WithOpName("http.server"),
Expand Down
4 changes: 3 additions & 1 deletion iris/sentryiris.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
hub = sentry.CurrentHub().Clone()
}

hub.Client().SetSDKIdentifier(sdkIdentifier)
if client := hub.Client(); client != nil {
client.SetSDKIdentifier(sdkIdentifier)
}

Check warning on line 60 in iris/sentryiris.go

View check run for this annotation

Codecov / codecov/patch

iris/sentryiris.go#L58-L60

Added lines #L58 - L60 were not covered by tests

hub.Scope().SetRequest(ctx.Request())
ctx.Values().Set(valuesKey, hub)
Expand Down
4 changes: 3 additions & 1 deletion martini/sentrymartini.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
hub = sentry.CurrentHub().Clone()
}

hub.Client().SetSDKIdentifier(sdkIdentifier)
if client := hub.Client(); client != nil {
client.SetSDKIdentifier(sdkIdentifier)
}

Check warning on line 55 in martini/sentrymartini.go

View check run for this annotation

Codecov / codecov/patch

martini/sentrymartini.go#L53-L55

Added lines #L53 - L55 were not covered by tests

hub.Scope().SetRequest(r)
ctx.Map(hub)
Expand Down
4 changes: 3 additions & 1 deletion negroni/sentrynegroni.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
hub = sentry.CurrentHub().Clone()
}

hub.Client().SetSDKIdentifier(sdkIdentifier)
if client := hub.Client(); client != nil {
client.SetSDKIdentifier(sdkIdentifier)
}

Check warning on line 56 in negroni/sentrynegroni.go

View check run for this annotation

Codecov / codecov/patch

negroni/sentrynegroni.go#L54-L56

Added lines #L54 - L56 were not covered by tests

hub.Scope().SetRequest(r)
ctx = sentry.SetHubOnContext(
Expand Down