Bug: fix panic on nil user fetch - #2442
Merged
Merged
Conversation
matoszz
enabled auto-merge (squash)
May 29, 2026 20:53
golanglemonade
approved these changes
May 29, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



I randomly had an existing local UI session and needed to purge the core server / restart, so i did that, and when I went to the browser the URL was on localhost:3001/policies (or similar, and probably had existing cookies and tokens) and when i refreshed the page, i got a huge flood of panics from the core server console
1({0x125914078, 0x1f05937b2cc0}) /Users/manderson/go/pkg/mod/github.com/theopenlane/echo-prometheus@v0.1.0/middleware.go:109 +0xec github.com/theopenlane/echox/middleware.BodyDumpConfig.ToMiddleware.func1.1({0x125914078, 0x1f05937b2cc0}) /Users/manderson/go/pkg/mod/github.com/theopenlane/echox@v0.3.0/middleware/body_dump.go:76 +0x27c github.com/theopenlane/echox/middleware.RecoverConfig.ToMiddleware.func1.1({0x125914078, 0x1f05937b2cc0}) /Users/manderson/go/pkg/mod/github.com/theopenlane/echox@v0.3.0/middleware/recover.go:115 +0xd8 github.com/theopenlane/core/pkg/logx.LoggingMiddleware.func1.1({0x125914230, 0x1f05955f4000}) /Users/manderson/core/pkg/logx/middleware.go:125 +0x438 github.com/theopenlane/echox/middleware.RequestIDConfig.ToMiddleware.func1.1({0x125914230, 0x1f05955f4000}) /Users/manderson/go/pkg/mod/github.com/theopenlane/echox@v0.3.0/middleware/request_id.go:65 +0xec github.com/theopenlane/echox.(*Echo).ServeHTTP(0x1f0594db25a0, {0x1257dba60, 0x1f0593481770}, 0x1f059cbd97c0) /Users/manderson/go/pkg/mod/github.com/theopenlane/echox@v0.3.0/echo.go:692 +0x194 net/http.serverHandler.ServeHTTP({0x12577abb0?}, {0x1257dba60?, 0x1f0593481770?}, 0x1?) /Users/manderson/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.3.darwin-arm64/src/net/http/server.go:3311 +0xb0 net/http.(*conn).serve(0x1f0594d582d0, {0x1257f3718, 0x1f05925a5a10}) /Users/manderson/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.3.darwin-arm64/src/net/http/server.go:2073 +0x7f4 created by net/http.(*Server).Serve in goroutine 1 /Users/manderson/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.3.darwin-arm64/src/net/http/server.go:3464 +0x2e0 goroutine 1 [IO wait]: internal/poll.runtime_pollWait(0x134515800, 0x72) /Users/manderson/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.3.darwin-arm64/src/runtime/netpoll.go:351 +0x48 internal/poll.(*pollDesc).wait(0xffffffffffffffff?, 0x1045709bc?, 0x0) /Users/manderson/go/pkg/mod/golang.org/too user_agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 12:52PM ERR internal/httpserve/server/stacktrace.go:39 | Error handling POST to /v1/refresh error=code=500, message=internal server error query=map[] remote_ip=::1 request_id=GyntwomaIQcuVbyDTllLJnPCUXaESTlB request_protocol=HTTP/1.1 severity=ERROR url=/v1/refresh user_agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36On a not-found error,
getUserDetailsByIDreturnsnil, err, and dereferencesuser.IDon the nil user; that's the nil pointer panic. This change prevents the panic in that branch.