{"id":"da8dca5cc1664517","repo":"labstack/echo","slug":"route-not-found-by-name","errorCode":null,"errorMessage":"route not found by name","messagePattern":"route not found by name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"route.go","lineNumber":186,"sourceCode":"\t\treturn nil, errors.New(\"route not found by path\")\n\t}\n\n\tresult := make(Routes, 0)\n\tfor _, rr := range r {\n\t\tif rr.Path == path {\n\t\t\tresult = append(result, rr)\n\t\t}\n\t}\n\tif len(result) == 0 {\n\t\treturn nil, errors.New(\"route not found by path\")\n\t}\n\treturn result, nil\n}\n\n// FilterByName searched for matching route info by name\nfunc (r Routes) FilterByName(name string) (Routes, error) {\n\tif r == nil {\n\t\treturn nil, errors.New(\"route not found by name\")\n\t}\n\n\tresult := make(Routes, 0)\n\tfor _, rr := range r {\n\t\tif rr.Name == name {\n\t\t\tresult = append(result, rr)\n\t\t}\n\t}\n\tif len(result) == 0 {\n\t\treturn nil, errors.New(\"route not found by name\")\n\t}\n\treturn result, nil\n}\n","sourceCodeStart":168,"sourceCodeEnd":200,"githubUrl":"https://github.com/labstack/echo/blob/05489dc1730161df26b72d1ae2a3ba6fb8178fc7/route.go#L168-L200","documentation":"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.","triggerScenarios":"Calling FilterByName on an uninitialized echo.Routes variable: `var rs echo.Routes; rs.FilterByName(\"users\")`.","commonSituations":"Refactors that drop the e.Routes() assignment; optional registration phases that leave a Routes field nil.","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"],"exampleFix":"// before\nvar rs echo.Routes\nrs.FilterByName(\"users\")\n// after\ne.Routes().FilterByName(\"users\")","handlingStrategy":"validation","validationCode":"routes := e.Routes()\nif routes == nil {\n    return errors.New(\"no routes registered\")\n}\n_, err := routes.FilterByName(name)","typeGuard":"func routesInitialized(r echo.Routes) bool { return r != nil }","tryCatchPattern":null,"preventionTips":["Derive Routes from e.Routes() at the call site","Nil-check after optional registration phases"],"tags":["routing","nil-check"],"analyzedSha":"05489dc1730161df26b72d1ae2a3ba6fb8178fc7","analyzedAt":"2026-08-04T21:32:47.783Z","schemaVersion":2}