labstack/echo · warning
route not found by method
Error message
route not found by method
What it means
Returned by Routes.FilterByMethod when the Routes receiver is nil. The function filters all routes of a given HTTP method; a nil slice means no route table exists at all, so the guard returns early rather than pretending there are zero matching routes (which would be indistinguishable from 'method not used').
Source
Thrown at route.go:150
// FindByMethodPath searched for matching route info by method and path
func (r Routes) FindByMethodPath(method string, path string) (RouteInfo, error) {
if r == nil {
return RouteInfo{}, errors.New("route not found by method and path")
}
for _, rr := range r {
if rr.Method == method && rr.Path == path {
return rr, nil
}
}
return RouteInfo{}, errors.New("route not found by method and path")
}
// FilterByMethod searched for matching route info by method
func (r Routes) FilterByMethod(method string) (Routes, error) {
if r == nil {
return nil, errors.New("route not found by method")
}
result := make(Routes, 0)
for _, rr := range r {
if rr.Method == method {
result = append(result, rr)
}
}
if len(result) == 0 {
return nil, errors.New("route not found by method")
}
return result, nil
}
// FilterByPath searched for matching route info by path
func (r Routes) FilterByPath(path string) (Routes, error) {
if r == nil {
return nil, errors.New("route not found by path")View on GitHub (pinned to 05489dc173)
Solutions
- Call FilterByMethod only after route registration is complete.
- Guard the receiver: if routes := e.Routes(); routes != nil { rs, err := routes.FilterByMethod(http.MethodGet) }.
- Always inspect the returned error before using the (possibly nil) Routes result.
- Prefer e.Routes() (never nil after Start) over hand-managed route slices.
Example fix
// before
var r echo.Routes
filtered, err := r.FilterByMethod(http.MethodGet) // r is nil -> error
// after
routes := e.Routes()
if routes == nil {
return nil, errors.New("routes not initialised")
}
filtered, err := routes.FilterByMethod(http.MethodGet) Defensive patterns
Strategy: validation
Validate before calling
func filterByMethod(routes echo.Routes, method string) (echo.Routes, error) {
if routes == nil {
return nil, errors.New("routes table is nil; register routes first")
}
return routes.FilterByMethod(strings.ToUpper(method))
} Prevention
- Only call FilterByMethod after route registration is complete.
- Guard the nil receiver before calling.
- Use e.Routes() rather than uninitialised local variables.
When it happens
Trigger: Calling FilterByMethod on a nil Routes value: var r echo.Routes; r.FilterByMethod(http.MethodGet), or on the result of e.Routes() before any route is registered.
Common situations: Querying routes during package init or before Echo has registered handlers; storing the routes in an uninitialised variable; or a loader that returns nil on error.
Related errors
- route not found by method and path
- route not found
- ResponseWriter does not implement 'Unwrap() http.ResponseWri
- response writer flushing is not supported
- file does not implement io.ReadSeeker
AI-assisted analysis of labstack/echo@05489dc173 (2026-08-04).
Data as JSON: /data/errors/8b5825d015bbeda6.json.
Report an issue: GitHub.