{"record":{"id":"dd4077368d4d9fdb","repo":"grpc/grpc-java","slug":"invalid-loadbalancingpolicy-loadbalancingpoli","errorCode":null,"errorMessage":"Invalid LoadBalancingPolicy: \" + loadBalancingPolicy","messagePattern":"Invalid LoadBalancingPolicy: \" \\+ loadBalancingPolicy","errorType":"validation","errorClass":"ResourceInvalidException","httpStatus":null,"severity":"error","filePath":"xds/src/main/java/io/grpc/xds/LoadBalancerConfigFactory.java","lineNumber":269,"sourceCode":"        } catch (InvalidProtocolBufferException e) {\n          throw new ResourceInvalidException(\n              \"Unable to unpack typedConfig for: \" + typedConfig.getTypeUrl(), e);\n        }\n        // The service config is expected to have a single root entry, where the name of that entry\n        // is the name of the policy. A Load balancer with this name must exist in the registry.\n        if (serviceConfig == null || LoadBalancerRegistry.getDefaultRegistry()\n            .getProvider(Iterables.getOnlyElement(serviceConfig.keySet())) == null) {\n          logger.log(XdsLogLevel.WARNING, \"Policy {0} not found in the LB registry, skipping\",\n              typedConfig.getTypeUrl());\n          continue;\n        } else {\n          return serviceConfig;\n        }\n      }\n\n      // If we could not find a Policy that we could both convert as well as find a provider for\n      // then we have an invalid LB policy configuration.\n      throw new ResourceInvalidException(\"Invalid LoadBalancingPolicy: \" + loadBalancingPolicy);\n    }\n\n    /**\n     * Converts a ring_hash {@link Any} configuration to service config format.\n     */\n    private static ImmutableMap<String, ?> convertRingHashConfig(RingHash ringHash)\n        throws ResourceInvalidException {\n      // The hash function needs to be validated here as it is not exposed in the returned\n      // configuration for later validation.\n      if (RingHash.HashFunction.XX_HASH != ringHash.getHashFunction()) {\n        throw new ResourceInvalidException(\n            \"Invalid ring hash function: \" + ringHash.getHashFunction());\n      }\n\n      return buildRingHashConfig(\n          ringHash.hasMinimumRingSize() ? ringHash.getMinimumRingSize().getValue() : null,\n          ringHash.hasMaximumRingSize() ? ringHash.getMaximumRingSize().getValue() : null);\n    }","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/xds/src/main/java/io/grpc/xds/LoadBalancerConfigFactory.java#L251-L287","documentation":"ResourceInvalidException thrown by LoadBalancerConfigFactory.convertToServiceConfig when the cluster's lb_policy/typed extension config could be converted, but no LoadBalancer Provider with the resulting policy name exists in the LoadBalancerRegistry. The xDS control plane requested a load-balancing policy this client neither recognizes nor has on its classpath.","triggerScenarios":"convertToServiceConfig (called from convertWrrLocalityConfig) receives a cluster whose LB policy name, after conversion, is not registered via LoadBalancerRegistry.getProvider(), e.g. an unknown custom policy name or a policy provider not on the classpath.","commonSituations":"Control plane sends a custom LB policy (custom LB extension) that grpc-java doesn't ship; grpc-xds artifact missing the provider dependency (e.g. missing grpc-rls or weighted-round-robin registration); policy name typo in Envoy config.","solutions":["Ensure the required grpc-java LB provider artifact is on the classpath (e.g. io.grpc:grpc-services includes providers) so the policy name resolves in LoadBalancerRegistry","Fix the control-plane config to use a policy supported by grpc-java (round_robin, weighted_round_robin, ring_hash, least_request, wrr_locality)","Upgrade grpc-xds to a version that supports the requested LB policy","Enable xDS client logging to see which policy name failed"],"exampleFix":"// before: control plane sends custom policy\n{\n  \"lb_policy\": { \"name\": \"my-custom-lb\", \"typed_config\": {...} }\n}\n// after: use a supported policy\n{\n  \"lb_policy\": { \"name\": \"round_robin\", \"typed_config\": { \"@type\": \"type.googleapis.com/envoy.extensions.transport_sockets...RoundRobin\" } }\n}","handlingStrategy":"try-catch","validationCode":"// verify the provider exists before requesting the policy from the control plane\nString policyName = /* policy name from cluster lb config */;\nif (LoadBalancerRegistry.getDefaultRegistry().getProvider(policyName) == null) {\n  throw new IllegalStateException(\"LB policy not registered: \" + policyName);\n}","typeGuard":null,"tryCatchPattern":"try {\n  /* create channel / start xDS client */;\n} catch (ResourceInvalidException e) {\n  if (e.getMessage().startsWith(\"Invalid LoadBalancingPolicy:\")) {\n    // fall back to a default resolver/service config\n    logger.warning(e.getMessage());\n  } else { throw e; }\n}","preventionTips":["Verify all required LB provider classes are on the runtime classpath","Only configure policies the grpc-java version supports","Log the full cluster resource when an unknown policy is rejected","Keep grpc-xds upgraded for newer policy support"],"tags":["xds","load-balancing","unsupported-policy","config"],"backgroundTag":"invalid-enum-value","analyzedSha":"64daddc1f3d1975670f769f3e97bde8b2ba32d25","analyzedAt":"2026-09-08T06:14:57.704Z","contentChangedAt":"2026-09-08T06:14:57.704Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}