{"record":{"id":"678ff82cd0fc3db1","repo":"grpc/grpc-go","slug":"rls-invalid-target-uri-in-lookup-service-s","errorCode":null,"errorMessage":"rls: invalid target URI in lookup_service %s","messagePattern":"rls: invalid target URI in lookup_service (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"balancer/rls/config.go","lineNumber":203,"sourceCode":"\nfunc parseRLSProto(rlsProto *rlspb.RouteLookupConfig) (*lbConfig, error) {\n\t// Validations specified on the `grpc_keybuilders` field are performed here.\n\tkbMap, err := keys.MakeBuilderMap(rlsProto)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// `lookup_service` field must be set and must parse as a target URI.\n\tlookupService := rlsProto.GetLookupService()\n\tif lookupService == \"\" {\n\t\treturn nil, fmt.Errorf(\"rls: empty lookup_service in route lookup config %+v\", rlsProto)\n\t}\n\tparsedTarget, err := url.Parse(lookupService)\n\tif err != nil {\n\t\t// url.Parse() fails if scheme is missing. Retry with default scheme.\n\t\tparsedTarget, err = url.Parse(resolver.GetDefaultScheme() + \":///\" + lookupService)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"rls: invalid target URI in lookup_service %s\", lookupService)\n\t\t}\n\t}\n\tif parsedTarget.Scheme == \"\" {\n\t\tparsedTarget.Scheme = resolver.GetDefaultScheme()\n\t}\n\tif resolver.Get(parsedTarget.Scheme) == nil {\n\t\treturn nil, fmt.Errorf(\"rls: unregistered scheme in lookup_service %s\", lookupService)\n\t}\n\n\tlookupServiceTimeout, err := convertDuration(rlsProto.GetLookupServiceTimeout())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"rls: failed to parse lookup_service_timeout in route lookup config %+v: %v\", rlsProto, err)\n\t}\n\tif lookupServiceTimeout == 0 {\n\t\tlookupServiceTimeout = defaultLookupServiceTimeout\n\t}\n\n\t// Validations performed here:","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/balancer/rls/config.go#L185-L221","documentation":"Emitted from parseRLSProto (config.go:203) when the lookup_service string cannot be parsed as a URI even after the balancer retries by prepending the default resolver scheme ('<default>:///' + lookupService). This is the fallback path; it fires when url.Parse rejects the string in both forms, i.e. the string contains control characters or other bytes that make it an invalid URI.","triggerScenarios":"lookupService contains characters that url.Parse refuses (e.g. raw spaces, control bytes, or malformed percent-encoding) in both the bare form and the scheme-prepended form.","commonSituations":"A copy-paste of a hostname with a stray space or newline; percent-encoding errors; a value that is actually a full connection string with extra metadata rather than a host:port / URI.","solutions":["Strip whitespace/newlines from the lookup_service value and re-test with url.Parse locally.","Provide a fully-qualified URI with an explicit scheme and authority, e.g. 'dns:///rls.example.com:443'.","Percent-encode any characters that are legal in a hostname but not in a URI path/query if they appear."],"exampleFix":"// before\n\"lookupService\": \"rls.example.com:443 \"\n\n// after\n\"lookupService\": \"dns:///rls.example.com:443\"","handlingStrategy":"validation","validationCode":"func parseLookupServiceURI(s string) (*url.URL, error) {\n    u, err := url.Parse(s)\n    if err != nil {\n        u, err = url.Parse(resolver.GetDefaultScheme() + \"/\" + s)\n        if err != nil {\n            return nil, fmt.Errorf(\"lookup_service %q is not a valid URI: %w\", s, err)\n        }\n    }\n    return u, nil\n}","typeGuard":"func isParsableLookupURI(s string) bool {\n    _, err := parseLookupServiceURI(s)\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Use fully-qualified URIs ('dns:///host:port') to avoid scheme-prepending ambiguity.","Trim whitespace from operator-supplied hostnames before templating.","Reject lookup_service values containing spaces or control bytes at config ingest."],"tags":["rls","lookup-service","uri","validation"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}