{"record":{"id":"c8ebae19a6f303b6","repo":"grpc/grpc-java","slug":"invalid-message-type-unpackedmessage-getclass-c8ebae","errorCode":null,"errorMessage":"Invalid message type: ${unpackedMessage.getClass()}","messagePattern":"Invalid message type: (.+?)","errorType":"validation","errorClass":"ResourceInvalidException","httpStatus":null,"severity":"error","filePath":"xds/src/main/java/io/grpc/xds/XdsEndpointResource.java","lineNumber":106,"sourceCode":"  @Override\n  public boolean shouldRetrieveResourceKeysForArgs() {\n    return true;\n  }\n\n  @Override\n  protected boolean isFullStateOfTheWorld() {\n    return false;\n  }\n\n  @Override\n  protected Class<ClusterLoadAssignment> unpackedClassName() {\n    return ClusterLoadAssignment.class;\n  }\n\n  @Override\n  protected EdsUpdate doParse(Args args, Message unpackedMessage) throws ResourceInvalidException {\n    if (!(unpackedMessage instanceof ClusterLoadAssignment)) {\n      throw new ResourceInvalidException(\"Invalid message type: \" + unpackedMessage.getClass());\n    }\n    return processClusterLoadAssignment((ClusterLoadAssignment) unpackedMessage);\n  }\n\n  private static boolean isEnabledXdsDualStack() {\n    return GrpcUtil.getFlag(GRPC_EXPERIMENTAL_XDS_DUALSTACK_ENDPOINTS, false);\n  }\n\n  private static EdsUpdate processClusterLoadAssignment(ClusterLoadAssignment assignment)\n      throws ResourceInvalidException {\n    Map<Integer, Set<Locality>> priorities = new HashMap<>();\n    Map<Locality, LocalityLbEndpoints> localityLbEndpointsMap = new LinkedHashMap<>();\n    List<Endpoints.DropOverload> dropOverloads = new ArrayList<>();\n    int maxPriority = -1;\n    for (io.envoyproxy.envoy.config.endpoint.v3.LocalityLbEndpoints localityLbEndpointsProto\n        : assignment.getEndpointsList()) {\n      StructOrError<LocalityLbEndpoints> structOrError =\n          parseLocalityLbEndpoints(localityLbEndpointsProto);","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/xds/src/main/java/io/grpc/xds/XdsEndpointResource.java#L88-L124","documentation":"XdsEndpointResource.doParse expects the unpacked Any payload of an EDS (EndpointDiscoveryResponse) resource to be a ClusterLoadAssignment protobuf. If the Any contains some other message type, the parser throws ResourceInvalidException naming the unexpected class.","triggerScenarios":"An EDS response resource whose type_url resolves (via the registered type registry/unpack) to a message that is not ClusterLoadAssignment — e.g. a misconfigured control plane sending the wrong resource body under an EDS type URL.","commonSituations":"Misbehaving or buggy xDS management server; custom control planes emitting wrong payloads; type-URL/registry mismatches after protobuf upgrades.","solutions":["Fix the management server to send ClusterLoadAssignment for EDS type URLs","Verify the resource's Any type_url matches io.grpc.xds EDS expectations","Capture the raw xDS response (grpc-xds debug logs) to inspect the actual payload","Update protobuf/xDS version alignment between control plane and grpc-java"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!resource.getMessage().is(ClusterLoadAssignment.class)) {\n  throw new IllegalArgumentException(\"EDS resource is not ClusterLoadAssignment\");\n}","typeGuard":"static boolean isClusterLoadAssignment(Any any) {\n  return any.is(ClusterLoadAssignment.class);\n}","tryCatchPattern":"try {\n  update = XdsEndpointResource.getInstance().parse(args, resource);\n} catch (ResourceInvalidException e) {\n  logger.warn(\"Bad EDS payload: {}\", e.getMessage());\n}","preventionTips":["Ensure the management server sends ClusterLoadAssignment under EDS type URLs","Log raw Any type_url on parse failures for diagnosis","Keep proto registries aligned between control plane and grpc-java"],"tags":["xds","eds","protobuf","grpc-java","control-plane"],"backgroundTag":"unexpected-api-response-shape","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"}