{"record":{"id":"013b52b80ba042ce","repo":"cilium/cilium","slug":"s-does-not-match-the-name-namespace-svc-for","errorCode":null,"errorMessage":"%s does not match the <name>.<namespace>(.svc) form","messagePattern":"(.+?) does not match the <name>\\.<namespace>\\(\\.svc\\) form","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/dial/resolver.go","lineNumber":228,"sourceCode":"// as a fallback when the frontends table takes too long to be initialized.\nfunc (sr *lbServiceResolver) resolveFromAPIServer(ctx context.Context, nsname types.NamespacedName) string {\n\tsvc, err := sr.cs.Slim().CoreV1().Services(nsname.Namespace).Get(ctx, nsname.Name, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\n\tif _, err := netip.ParseAddr(svc.Spec.ClusterIP); err != nil {\n\t\t// The ClusterIP is not a valid IP address (e.g., headless service)\n\t\treturn \"\"\n\t}\n\n\treturn svc.Spec.ClusterIP\n}\n\nfunc ServiceURLToNamespacedName(host string) (types.NamespacedName, error) {\n\ttokens := strings.Split(host, \".\")\n\tif len(tokens) < 2 {\n\t\treturn types.NamespacedName{}, fmt.Errorf(\"%s does not match the <name>.<namespace>(.svc) form\", host)\n\t}\n\n\tif len(tokens) >= 3 && tokens[2] != \"svc\" {\n\t\treturn types.NamespacedName{}, fmt.Errorf(\"%s does not match the <name>.<namespace>(.svc) form\", host)\n\t}\n\n\treturn types.NamespacedName{Namespace: tokens[1], Name: tokens[0]}, nil\n}\n\nvar _ Resolver = (*ServiceBackendResolver)(nil)\n\ntype ServiceBackendResolver struct {\n\tdb        *statedb.DB\n\tfrontends statedb.Table[*loadbalancer.Frontend]\n\n\tignoredInitializers []string\n\n\t// affinityCache is leveraged to preserve backend affinity when the resolver","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/dial/resolver.go#L210-L246","documentation":"ServiceURLToNamespacedName parses a service host in the form <name>.<namespace> or <name>.<namespace>.svc into a NamespacedName. It fails when the host splits into fewer than two dot-separated tokens — i.e. there is no namespace part. resolve calls it to convert FQDN-style service names into lookup keys.","triggerScenarios":"Calling ServiceBackendResolver.resolve / ServiceURLToNamespacedName with a host like 'mysvc' or 'localhost' — no dot-separated namespace component.","commonSituations":"Dialing a bare service name without a namespace; a URL whose host was misconfigured (missing .default.svc suffix); a CiliumNetworkPolicy or upstream config referencing a short name where the resolver requires the FQDN form.","solutions":["Use the fully qualified form: <name>.<namespace> (e.g. mysvc.default) or mysvc.default.svc","Use k8s short name only when the client supports cluster-local short-name expansion instead of this resolver","Validate the host string before calling resolve","Check policy/config sources that generate the URL for missing namespace suffixes"],"exampleFix":"// before\nresolve(\"http://mysvc\")\n// after\nresolve(\"http://mysvc.default.svc\")","handlingStrategy":"validation","validationCode":"func isValidSvcHost(host string) bool {\n\ttokens := strings.Split(host, \".\")\n\treturn len(tokens) >= 2 && (len(tokens) == 2 || tokens[2] == \"svc\")\n}","typeGuard":"func isNamespacedSvcHost(host string) bool {\n\tparts := strings.Split(host, \".\")\n\treturn len(parts) >= 2 && parts[0] != \"\" && parts[1] != \"\"\n}","tryCatchPattern":"nn, err := dial.ServiceURLToNamespacedName(host)\nif err != nil {\n\treturn fmt.Errorf(\"cannot resolve service host %q: %w (use <name>.<namespace>.svc form)\", host, err)\n}","preventionTips":["Always dial services by FQDN: <name>.<namespace>.svc","Never pass bare names or localhost to this resolver","Validate host contains at least one dot before resolving"],"tags":["kubernetes","dns","service-resolution"],"backgroundTag":"invalid-service-name-format","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}