{"record":{"id":"479e80ff4cfc831b","repo":"caddyserver/caddy","slug":"cannot-have-duplicate-named-routes-s","errorCode":null,"errorMessage":"cannot have duplicate named_routes: %s","messagePattern":"cannot have duplicate named_routes: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"caddyconfig/httpcaddyfile/httptype.go","lineNumber":531,"sourceCode":"\n\t\thandler, err := ParseSegmentAsSubroute(h)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tsubroute := handler.(*caddyhttp.Subroute)\n\t\troute := caddyhttp.Route{}\n\n\t\tif len(subroute.Routes) == 1 && len(subroute.Routes[0].MatcherSetsRaw) == 0 {\n\t\t\t// if there's only one route with no matcher, then we can simplify\n\t\t\troute.HandlersRaw = append(route.HandlersRaw, subroute.Routes[0].HandlersRaw[0])\n\t\t} else {\n\t\t\t// otherwise we need the whole subroute\n\t\t\troute.HandlersRaw = []json.RawMessage{caddyconfig.JSONModuleObject(handler, \"handler\", subroute.CaddyModule().ID.Name(), h.warnings)}\n\t\t}\n\n\t\tkey := sb.block.GetKeysText()[0]\n\t\tif _, exists := namedRoutes[key]; exists {\n\t\t\treturn nil, fmt.Errorf(\"cannot have duplicate named_routes: %s\", key)\n\t\t}\n\t\tnamedRoutes[key] = &route\n\n\t\t// remember which named routes this named route invokes,\n\t\t// so they can also be attached to any server that invokes\n\t\t// this one\n\t\tif state[namedRouteKey] != nil {\n\t\t\tfor name := range state[namedRouteKey].(map[string]struct{}) {\n\t\t\t\tnamedRouteInvokes[key] = append(namedRouteInvokes[key], name)\n\t\t\t}\n\t\t\tstate[namedRouteKey] = nil\n\t\t}\n\t}\n\toptions[\"named_routes\"] = namedRoutes\n\toptions[\"named_route_invokes\"] = namedRouteInvokes\n\n\treturn filtered, nil\n}","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/caddyconfig/httpcaddyfile/httptype.go#L513-L549","documentation":"Error \"cannot have duplicate named_routes: %s\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at caddyconfig/httpcaddyfile/httptype.go:531 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename one of the duplicate named routes so each name is unique across the Caddyfile."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}