{"record":{"id":"f093997c8a04058d","repo":"caddyserver/caddy","slug":"cannot-invoke-named-route-s-which-was-not-defi","errorCode":null,"errorMessage":"cannot invoke named route '%s', which was not defined","messagePattern":"cannot invoke named route '(.+?)', which was not defined","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"caddyconfig/httpcaddyfile/httptype.go","lineNumber":758,"sourceCode":"\t\tfor _, sblock := range p.serverBlocks {\n\t\t\tif len(sblock.pile[namedRouteKey]) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor _, value := range sblock.pile[namedRouteKey] {\n\t\t\t\tif srv.NamedRoutes == nil {\n\t\t\t\t\tsrv.NamedRoutes = map[string]*caddyhttp.Route{}\n\t\t\t\t}\n\t\t\t\t// named routes may invoke other named routes, so\n\t\t\t\t// resolve the set of invoked names transitively\n\t\t\t\tnames := []string{value.Value.(string)}\n\t\t\t\tfor len(names) > 0 {\n\t\t\t\t\tname := names[0]\n\t\t\t\t\tnames = names[1:]\n\t\t\t\t\tif _, ok := srv.NamedRoutes[name]; ok {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t\tif configuredNamedRoutes[name] == nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"cannot invoke named route '%s', which was not defined\", name)\n\t\t\t\t\t}\n\t\t\t\t\tsrv.NamedRoutes[name] = configuredNamedRoutes[name]\n\t\t\t\t\tnames = append(names, namedRouteInvokes[name]...)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// create a subroute for each site in the server block\n\t\tfor _, sblock := range p.serverBlocks {\n\t\t\tmatcherSetsEnc, err := st.compileEncodedMatcherSets(sblock)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"server block %v: compiling matcher sets: %v\", sblock.block.Keys, err)\n\t\t\t}\n\n\t\t\thosts := sblock.hostsFromKeys(false)\n\n\t\t\t// emit warnings if user put unspecified IP addresses; they probably want the bind directive\n\t\t\tfor _, h := range hosts {","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/caddyconfig/httpcaddyfile/httptype.go#L740-L776","documentation":"Error \"cannot invoke named route '%s', which was not defined\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at caddyconfig/httpcaddyfile/httptype.go:758 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define the named route before invoking it, or fix the name used in the 'invoke' directive to match a defined named route."],"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-15T22:17:37.221Z"}