Skip to content

panic: hash of unhashable type #1131

@orsinium

Description

@orsinium

How do you use Sentry?

Sentry SaaS (sentry.io)

SDK version

v0.36.2

Go version

1.25.3

Are you using Go Modules?

yes

Steps to reproduce

Sentry panics when logging an unhashable error. Looking at the traceback, I believe that the panic comes from the following code in exception.go:

	if t.Comparable() {
		if _, ok := v.comparable[err]; ok { // <- panics here
			return true
		}
		v.comparable[err] = struct{}{}
		return false
	}

According to the docs for reflect.Type.Comparable:

	// Even if Comparable returns true, the comparison may still panic.
	// For example, values of interface type are comparable,
	// but the comparison will panic if their dynamic type is not comparable.

I'm still working on a minimal reproducible example.

Expected result

no panic 🙃

Actual result

2025/11/11 09:14:45 http: panic serving 172.18.0.1:59848: hash of unhashable type: valdo.Errors
goroutine 55 [running]:
net/http.(*conn).serve.func1()
	/usr/local/go/src/net/http/server.go:1943 +0xd3
panic({0x16597c0?, 0x1708b80?})
	/usr/local/go/src/runtime/panic.go:783 +0x132
go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End.deferwrap1()
	/go/pkg/mod/go.opentelemetry.io/otel/sdk@v1.38.0/trace/span.go:468 +0x25
go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End(0xc0017043c0, {0x0, 0x0, 0xc0018261c0?})
	/go/pkg/mod/go.opentelemetry.io/otel/sdk@v1.38.0/trace/span.go:517 +0xbf2
panic({0x16597c0?, 0x1708b80?})
	/usr/local/go/src/runtime/panic.go:783 +0x132
github.com/ourmindbv/ourmind-backend/ourmind.recoverWithSentry(0xc001d06720, 0xc00172f680)
	/app/ourmind/sentry.go:52 +0x9c
panic({0x16597c0?, 0x1708b80?})
	/usr/local/go/src/runtime/panic.go:783 +0x132
github.com/getsentry/sentry-go.(*visited).seenError(0xc00284dd90, {0x78c5935a3370, 0xc00277eb70})
	/go/pkg/mod/github.com/getsentry/sentry-go@v0.36.2/exception.go:28 +0x7f
github.com/getsentry/sentry-go.convertErrorDFS({0x78c5935a3370, 0xc00277eb70}, 0xc00284dd18, 0x0, {0x0, 0x0}, 0xc00284dd90, 0x64, 0x0)
	/go/pkg/mod/github.com/getsentry/sentry-go@v0.36.2/exception.go:75 +0x91
github.com/getsentry/sentry-go.convertErrorToExceptions({0x78c5935a3370, 0xc00277eb70}, 0x64)
	/go/pkg/mod/github.com/getsentry/sentry-go@v0.36.2/exception.go:49 +0x196
github.com/getsentry/sentry-go.(*Event).SetException(...)
	/go/pkg/mod/github.com/getsentry/sentry-go@v0.36.2/interfaces.go:416
github.com/getsentry/sentry-go/slog.DefaultConverter(0x1, 0x0, {0xc001816b60?, 0x16bf2a0?, 0xc00284e628?}, {0xa57c820?, 0x0?, 0x0?}, 0xc001870480, 0xc001d06720)
	/go/pkg/mod/github.com/getsentry/sentry-go/slog@v0.36.2/converter.go:54 +0x498
github.com/getsentry/sentry-go/slog.(*eventHandler).Handle(_, {_, _}, {{0xc23cdd815177b74d, 0x17d3618de, 0xa55a6a0}, {0x182d60a, 0x29}, 0x4, 0x132b956, ...})
	/go/pkg/mod/github.com/getsentry/sentry-go/slog@v0.36.2/sentryslog.go:190 +0x343
github.com/getsentry/sentry-go/slog.(*SentryHandler).Handle(_, {_, _}, {{0xc23cdd815177b74d, 0x17d3618de, 0xa55a6a0}, {0x182d60a, 0x29}, 0x4, 0x132b956, ...})
	/go/pkg/mod/github.com/getsentry/sentry-go/slog@v0.36.2/sentryslog.go:142 +0x9b
github.com/ourmindbv/ourmind-backend/ourmind.(*chainHandler).Handle(_, {_, _}, {{0xc23cdd815177b74d, 0x17d3618de, 0xa55a6a0}, {0x182d60a, 0x29}, 0x4, 0x132b956, ...})
...

Metadata

Metadata

Assignees

Labels

No fields configured for issues without a type.

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions