{"record":{"id":"3ffb06bbe622aec0","repo":"grpc/grpc-java","slug":"cluster-cluster-getname-unsupported-lb","errorCode":null,"errorMessage":"Cluster \" + cluster.getName() + \": unsupported lb policy: \" + cluster.getLbPolicy()","messagePattern":"Cluster \" \\+ cluster\\.getName\\(\\) \\+ \": unsupported lb policy: \" \\+ cluster\\.getLbPolicy\\(\\)","errorType":"validation","errorClass":"ResourceInvalidException","httpStatus":null,"severity":"error","filePath":"xds/src/main/java/io/grpc/xds/LoadBalancerConfigFactory.java","lineNumber":422,"sourceCode":"     * Cluster}.\n     *\n     * @throws ResourceInvalidException If the {@link Cluster} has an invalid LB configuration.\n     */\n    static ImmutableMap<String, ?> convertToServiceConfig(Cluster cluster,\n        boolean enableLeastRequest) throws ResourceInvalidException {\n      switch (cluster.getLbPolicy()) {\n        case RING_HASH:\n          return convertRingHashConfig(cluster);\n        case ROUND_ROBIN:\n          return buildWrrLocalityConfig(buildRoundRobinConfig());\n        case LEAST_REQUEST:\n          if (enableLeastRequest) {\n            return buildWrrLocalityConfig(convertLeastRequestConfig(cluster));\n          }\n          break;\n        default:\n      }\n      throw new ResourceInvalidException(\n          \"Cluster \" + cluster.getName() + \": unsupported lb policy: \" + cluster.getLbPolicy());\n    }\n\n    /**\n     * Creates a new ring_hash service config JSON object based on the old {@link RingHashLbConfig}\n     * config message.\n     */\n    private static ImmutableMap<String, ?> convertRingHashConfig(Cluster cluster)\n        throws ResourceInvalidException {\n      RingHashLbConfig lbConfig = cluster.getRingHashLbConfig();\n\n      // The hash function needs to be validated here as it is not exposed in the returned\n      // configuration for later validation.\n      if (lbConfig.getHashFunction() != RingHashLbConfig.HashFunction.XX_HASH) {\n        throw new ResourceInvalidException(\n            \"Cluster \" + cluster.getName() + \": invalid ring hash function: \" + lbConfig);\n      }\n","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/xds/src/main/java/io/grpc/xds/LoadBalancerConfigFactory.java#L404-L440","documentation":"convertToServiceConfig maps an Envoy Cluster's lb_policy enum to a gRPC service config. Only ROUND_ROBIN, LEAST_REQUEST (when enabled) and their wrappers are supported; any other lb_policy (e.g. RANDOM, MAGLEV, CLUSTER_PROVIDED in this path) has no gRPC equivalent, so the resource is rejected as invalid.","triggerScenarios":"A CDS Cluster whose lb_policy field is an unsupported value (falls to the default branch of the switch) is converted while building the service config, e.g. when a wrr_locality/ring_hash conversion path ultimately delegates to convertToServiceConfig with an unsupported policy.","commonSituations":"Control plane assigning MAGLEV or RANDOM to a cluster targeted at gRPC clients; Istio/Envoy configs reused verbatim for gRPC; newer Envoy lb policies not yet mapped by the grpc-xds version in use.","solutions":["Set the Cluster's lb_policy to ROUND_ROBIN (or RING_HASH/LEAST_REQUEST where supported) for clusters consumed by gRPC clients","Upgrade grpc-xds to a version supporting the policy you need","Route unsupported policies through a non-gRPC proxy tier instead","Check grpc-xds release notes for which lb policies are supported per version"],"exampleFix":"# before (Envoy cluster)\nlb_policy: MAGLEV\n# after\nlb_policy: ROUND_ROBIN","handlingStrategy":"validation","validationCode":"// Only emit lb policies gRPC supports:\nSet<String> supported = Set.of(\"ROUND_ROBIN\", \"RING_HASH\", \"LEAST_REQUEST\");\nif (!supported.contains(cluster.getLbPolicy().name())) {\n  throw new IllegalArgumentException(\"lb_policy not supported by gRPC: \" + cluster.getLbPolicy());\n}","typeGuard":null,"tryCatchPattern":"try {\n  serviceConfig = convertToServiceConfig(cluster, ...);\n} catch (ResourceInvalidException e) {\n  logger.warning(\"Cluster rejected: \" + e.getMessage());\n  // route cluster through proxy tier or use ROUND_ROBIN fallback\n}","preventionTips":["Use ROUND_ROBIN/RING_HASH for clusters consumed by gRPC clients","Check grpc-xds docs for supported lb policies per release","Don't copy Envoy-only policies (MAGLEV, RANDOM) into gRPC-bound clusters"],"tags":["grpc","xds","load-balancing","unsupported-policy"],"backgroundTag":"unsupported-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"}