Skip to content

Bug: fix panic on nil user fetch - #2442

Merged
matoszz merged 2 commits into
mainfrom
bug-fixpanicrefresh
May 29, 2026
Merged

Bug: fix panic on nil user fetch#2442
matoszz merged 2 commits into
mainfrom
bug-fixpanicrefresh

Conversation

@matoszz

@matoszz matoszz commented May 29, 2026

Copy link
Copy Markdown
Member

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.36

On a not-found error, getUserDetailsByID returns nil, err, and dereferences user.ID on the nil user; that's the nil pointer panic. This change prevents the panic in that branch.

@matoszz
matoszz requested a review from a team as a code owner May 29, 2026 20:51
@github-actions github-actions Bot added bug Something isn't working httpserve labels May 29, 2026
@matoszz
matoszz enabled auto-merge (squash) May 29, 2026 20:53
@sonarqubecloud

Copy link
Copy Markdown

@matoszz
matoszz merged commit 8314316 into main May 29, 2026
16 checks passed
@matoszz
matoszz deleted the bug-fixpanicrefresh branch May 29, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working httpserve

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants