{"id":"50e5a2bb4891bfd0","repo":"labstack/echo","slug":"panic-errs-collected-from-g-addroute-failures-in","errorCode":null,"errorMessage":"panic: errs collected from g.AddRoute failures in Group.Match","messagePattern":"panic: errs collected from g\\.AddRoute failures in Group\\.Match","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"group.go","lineNumber":125,"sourceCode":"// Match implements `Echo#Match()` for sub-routes within the Group. Panics on error.\nfunc (g *Group) Match(methods []string, path string, handler HandlerFunc, middleware ...MiddlewareFunc) Routes {\n\terrs := make([]error, 0)\n\tris := make(Routes, 0)\n\tfor _, m := range methods {\n\t\tri, err := g.AddRoute(Route{\n\t\t\tMethod:      m,\n\t\t\tPath:        path,\n\t\t\tHandler:     handler,\n\t\t\tMiddlewares: middleware,\n\t\t})\n\t\tif err != nil {\n\t\t\terrs = append(errs, err)\n\t\t\tcontinue\n\t\t}\n\t\tris = append(ris, ri)\n\t}\n\tif len(errs) > 0 {\n\t\tpanic(errs) // this is how `v4` handles errors. `v5` has methods to have panic-free usage\n\t}\n\treturn ris\n}\n\n// Group creates a new sub-group with prefix and optional sub-group-level middleware.\n//\n// Important! Group middlewares are executed in case there was no exact route match as by default Group registers\n// `/*` NotFound routes for itself. If this kind of behavior is not needed, then create an Echo instance with the ` noAutoRegisterRoutes `\n// flag set to true. Example `echo.NewWithConfig(echo.Config{NoGroupAutoRegister404Routes: true})`.\nfunc (g *Group) Group(prefix string, middleware ...MiddlewareFunc) (sg *Group) {\n\tm := make([]MiddlewareFunc, 0, len(g.middleware)+len(middleware))\n\tm = append(m, g.middleware...)\n\tm = append(m, middleware...)\n\tsg = g.echo.Group(g.prefix+prefix, m...)\n\treturn\n}\n\n// Static implements `Echo#Static()` for sub-routes within the Group.","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/labstack/echo/blob/05489dc1730161df26b72d1ae2a3ba6fb8178fc7/group.go#L107-L143","documentation":"Panicked inside Group.Match (group.go:125) after collecting errors from one or more g.AddRoute calls across the requested HTTP methods. Match registers the same path for multiple methods; any AddRoute failures are accumulated in an errs slice, and if non-empty, the whole slice is panicked. This is v4's error model — v5 returns errors instead.","triggerScenarios":"Calling g.Match([]string{\"GET\",\"POST\"}, path, h) where one or more method+path combinations conflict with already-registered routes or are rejected by the router (invalid path syntax, conflicting param names, duplicate static+param overlap).","commonSituations":"Registering a path with mismatched parameter names across methods; path syntax errors (e.g. ':id' vs '*id'); route conflicts where a static path shadows a parameter route; typos in HTTP method names.","solutions":["Inspect the panicked []error slice to see exactly which method/path failed.","Ensure consistent parameter names for the same path across all methods in the Match call.","Resolve route conflicts (duplicate registrations, static-vs-param collisions) before calling Match.","Register methods individually with g.Add to isolate which registration fails."],"exampleFix":"// before: inconsistent param names cause conflict\ng.Match([]string{\"GET\",\"POST\"}, \"/users/:userId\", h) // elsewhere /users/:id exists\n// after: use consistent param names everywhere\ng.Match([]string{\"GET\",\"POST\"}, \"/users/:id\", h)","handlingStrategy":"validation","validationCode":"// Register methods individually and collect errors instead of letting Match panic.\nfunc matchSafe(g *echo.Group, methods []string, path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) (err error) {\n    for _, meth := range methods {\n        // echo v4 Add panics; wrap in recover to capture the error.\n        func() {\n            defer func() {\n                if r := recover(); r != nil {\n                    err = fmt.Errorf(\"register %s %s: %v\", meth, path, r)\n                }\n            }()\n            g.Add(meth, path, h, m...)\n        }()\n        if err != nil { return }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use consistent parameter names for the same path across all HTTP methods.","Resolve static/param route conflicts before registering.","Register methods one-by-one to isolate which combination fails."],"tags":["group","router","panic","startup","routing"],"analyzedSha":"05489dc1730161df26b72d1ae2a3ba6fb8178fc7","analyzedAt":"2026-08-04T21:32:47.783Z","schemaVersion":2}