{"record":{"id":"2fce5700401fb2a9","repo":"grpc/grpc-java","slug":"invalid-message-type-unpackedmessage-getclass-2fce57","errorCode":null,"errorMessage":"Invalid message type: ${unpackedMessage.getClass()}","messagePattern":"Invalid message type: (.+?)","errorType":"exception","errorClass":"ResourceInvalidException","httpStatus":null,"severity":"error","filePath":"xds/src/main/java/io/grpc/xds/XdsRouteConfigureResource.java","lineNumber":132,"sourceCode":"  public boolean shouldRetrieveResourceKeysForArgs() {\n    return false;\n  }\n\n  @Override\n  protected boolean isFullStateOfTheWorld() {\n    return false;\n  }\n\n  @Override\n  protected Class<RouteConfiguration> unpackedClassName() {\n    return RouteConfiguration.class;\n  }\n\n  @Override\n  protected RdsUpdate doParse(XdsResourceType.Args args, Message unpackedMessage)\n      throws ResourceInvalidException {\n    if (!(unpackedMessage instanceof RouteConfiguration)) {\n      throw new ResourceInvalidException(\"Invalid message type: \" + unpackedMessage.getClass());\n    }\n    return processRouteConfiguration(\n        (RouteConfiguration) unpackedMessage, FilterRegistry.getDefaultRegistry(), args);\n  }\n\n  private static RdsUpdate processRouteConfiguration(\n      RouteConfiguration routeConfig, FilterRegistry filterRegistry, XdsResourceType.Args args)\n      throws ResourceInvalidException {\n    return new RdsUpdate(extractVirtualHosts(routeConfig, filterRegistry, args));\n  }\n\n  static List<VirtualHost> extractVirtualHosts(\n      RouteConfiguration routeConfig, FilterRegistry filterRegistry, XdsResourceType.Args args)\n      throws ResourceInvalidException {\n    Map<String, PluginConfig> pluginConfigMap = new HashMap<>();\n    ImmutableSet.Builder<String> optionalPlugins = ImmutableSet.builder();\n\n    if (enableRouteLookup) {","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/xds/src/main/java/io/grpc/xds/XdsRouteConfigureResource.java#L114-L150","documentation":"The RDS resource type parser expected the unpacked Any message to be an Envoy RouteConfiguration, but received a different message type. This is a type invariant check in doParse; it indicates the management server sent a resource whose packed message does not match the expected type_url for RDS.","triggerScenarios":"XdsRouteConfigureResource.doParse receiving an unpackedMessage that is not io.envoyproxy.envoy.config.route.v3.RouteConfiguration — e.g. a Listener, Cluster, or other Envoy proto sent under a route-configuration type_url.","commonSituations":"Misbehaving or buggy control plane sending resources under the wrong type_url; manually injecting protobufs in tests; mixing Envoy API versions where the unpacked type differs.","solutions":["Fix the management server to send RouteConfiguration protos for RDS resources with the correct type_url","Verify the resource's Any.type_url matches envoy.config.route.v3.RouteConfiguration","In tests, pass a RouteConfiguration message to the parser instead of another type"],"exampleFix":"// before\nAny any = Any.pack(Listener.getDefaultInstance()); // wrong type\n// after\nAny any = Any.pack(RouteConfiguration.newBuilder()...build());","handlingStrategy":"type-guard","validationCode":"// Before feeding to the parser, confirm the unpacked type\nif (!(unpacked instanceof RouteConfiguration)) {\n  throw new IllegalArgumentException(\"Expected RouteConfiguration, got \"\n      + unpacked.getClass());\n}","typeGuard":"static boolean isRouteConfiguration(Message msg) {\n  return msg instanceof RouteConfiguration;\n}","tryCatchPattern":"try {\n  RdsUpdate update = XdsRouteConfigureResource.parseRds(args, any);\n} catch (ResourceInvalidException e) {\n  log.error(\"Bad RDS resource payload: {}\", e.getMessage());\n}","preventionTips":["Ensure the control plane packs the right proto under the RDS type_url","Add contract tests matching type_url to unpacked message types","Pin Envoy API versions consistently between producer and consumer"],"tags":["xds","grpc","protobuf","type-mismatch"],"backgroundTag":"type-mismatch","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"}