labstack/echo · error
route not found by name
Error message
route not found by name
What it means
Returned by Routes.FilterByName (route.go:185-187) when the receiver Routes slice is nil. The lookup helper was invoked on a nil collection rather than on e.Routes(). Same nil-receiver guard as the path variant.
Source
Thrown at route.go:186
return nil, errors.New("route not found by path")
}
result := make(Routes, 0)
for _, rr := range r {
if rr.Path == path {
result = append(result, rr)
}
}
if len(result) == 0 {
return nil, errors.New("route not found by path")
}
return result, nil
}
// FilterByName searched for matching route info by name
func (r Routes) FilterByName(name string) (Routes, error) {
if r == nil {
return nil, errors.New("route not found by name")
}
result := make(Routes, 0)
for _, rr := range r {
if rr.Name == name {
result = append(result, rr)
}
}
if len(result) == 0 {
return nil, errors.New("route not found by name")
}
return result, nil
}
View on GitHub (pinned to 05489dc173)
Solutions
- Call FilterByName on the non-nil collection returned by e.Routes()
- Nil-check before calling: if rs != nil { ... }
- Ensure registration completed: assert len(e.Routes()) > 0
Example fix
// before
var rs echo.Routes
rs.FilterByName("users")
// after
e.Routes().FilterByName("users") Defensive patterns
Strategy: validation
Validate before calling
routes := e.Routes()
if routes == nil {
return errors.New("no routes registered")
}
_, err := routes.FilterByName(name) Type guard
func routesInitialized(r echo.Routes) bool { return r != nil } Prevention
- Derive Routes from e.Routes() at the call site
- Nil-check after optional registration phases
When it happens
Trigger: Calling FilterByName on an uninitialized echo.Routes variable: `var rs echo.Routes; rs.FilterByName("users")`.
Common situations: Refactors that drop the e.Routes() assignment; optional registration phases that leave a Routes field nil.
Related errors
- route not found by path
- router has no routes to remove
- could not find route to remove by given path
- could not find route to remove by given path and method
- adding route without handler function
AI-assisted analysis of labstack/echo@05489dc173 (2026-08-04).
Data as JSON: /data/errors/da8dca5cc1664517.json.
Report an issue: GitHub.