#749·mux

[BUG] runtime error in (*routeRegexp).Match

Author: streamer45Created Jan 10, 2024Updated Aug 23, 2024
Labelsbug

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Code panics

Expected Behavior

Not to panic but return an error

Steps To Reproduce

It's a sporadic issue we spotted through automation (Sentry) so hard to tell how it could be reproduced but somehow the regexp pointer is nil when the code attempts to match.

Anything else?

Stacktrace

runtime.errorString: runtime error: invalid memory address or nil pointer dereference
  File "regexp/exec.go", line 527, in (*Regexp).doExecute
  File "regexp/exec.go", line 514, in (*Regexp).doMatch
  File "regexp/regexp.go", line 533, in (*Regexp).MatchString
  File "github.com/gorilla/[email protected]/regexp.go", line 193, in (*routeRegexp).Match
  File "github.com/gorilla/[email protected]/route.go", line 50, in (*Route).Match
  File "github.com/gorilla/[email protected]/mux.go", line 138, in (*Router).Match
  File "github.com/gorilla/[email protected]/route.go", line 50, in (*Route).Match
  File "github.com/gorilla/[email protected]/mux.go", line 138, in (*Router).Match
  File "github.com/gorilla/[email protected]/route.go", line 50, in (*Route).Match
  File "github.com/gorilla/[email protected]/mux.go", line 138, in (*Router).Match
  File "github.com/gorilla/[email protected]/mux.go", line 196, in (*Router).ServeHTTP
  File "net/http/server.go", line 2109, in HandlerFunc.ServeHTTP
  File "net/http/server.go", line 2947, in serverHandler.ServeHTTP
  File "net/http/server.go", line 1991, in (*conn).serve