{"record":{"id":"0bd30c0ffb1ce860","repo":"grpc/grpc-java","slug":"invalid-resource-in-address-proto-0bd30c","errorCode":null,"errorMessage":"Invalid Resource in address proto","messagePattern":"Invalid Resource in address proto","errorType":"validation","errorClass":"ResourceInvalidException","httpStatus":null,"severity":"error","filePath":"xds/src/main/java/io/grpc/xds/XdsEndpointResource.java","lineNumber":319,"sourceCode":"              .add(\"dropPolicies\", dropPolicies)\n              .toString();\n    }\n  }\n\n  public static class AddressMetadataParser implements MetadataValueParser {\n\n    @Override\n    public String getTypeUrl() {\n      return \"type.googleapis.com/envoy.config.core.v3.Address\";\n    }\n\n    @Override\n    public java.net.SocketAddress parse(Any any) throws ResourceInvalidException {\n      SocketAddress socketAddress;\n      try {\n        socketAddress = any.unpack(Address.class).getSocketAddress();\n      } catch (InvalidProtocolBufferException ex) {\n        throw new ResourceInvalidException(\"Invalid Resource in address proto\", ex);\n      }\n      validateAddress(socketAddress);\n\n      String ip = socketAddress.getAddress();\n      int port = socketAddress.getPortValue();\n\n      try {\n        return new InetSocketAddress(InetAddresses.forString(ip), port);\n      } catch (IllegalArgumentException e) {\n        throw createException(\"Invalid IP address or port: \" + ip + \":\" + port);\n      }\n    }\n\n    private void validateAddress(SocketAddress socketAddress) throws ResourceInvalidException {\n      if (socketAddress.getAddress().isEmpty()) {\n        throw createException(\"Address field is empty or invalid.\");\n      }\n      long port = Integer.toUnsignedLong(socketAddress.getPortValue());","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/grpc/grpc-java/blob/64daddc1f3d1975670f769f3e97bde8b2ba32d25/xds/src/main/java/io/grpc/xds/XdsEndpointResource.java#L301-L337","documentation":"This parser unpacks an envoy Address proto from an google.protobuf.Any (used for extraAddresses / endpoint address parsing). If the Any cannot be unpacked (wrong type URL or corrupted bytes), an InvalidProtocolBufferException is converted to ResourceInvalidException('Invalid Resource in address proto').","triggerScenarios":"An Any field in an EDS resource (e.g. endpoint address or extra_addresses) has a type_url that does not match type.googleapis.com/envoy.config.core.v3.Address or whose payload bytes are not a valid Address proto; unpack(Any -> Address) throws and the resource is rejected.","commonSituations":"Custom management server packs the wrong message type into the Any; version skew between control plane proto packages (envoy v2 vs v3 Any payloads); corrupted or hand-mangled serialized resources in tests.","solutions":["Ensure the control plane sets type_url to the envoy.config.core.v3.Address type URL and packs a valid Address message","Check control plane/client proto version skew (v3 Address expected, not v2)","Regenerate or re-serialize the offending resource and re-push it","Log the Any's type_url on the management server to confirm what was actually sent"],"exampleFix":"// before\nany { type_url: \"type.googleapis.com/envoy.config.core.v3.SocketAddress\" value: \"...\" }\n// after\nany { type_url: \"type.googleapis.com/envoy.config.core.v3.Address\" value: \"...\" }","handlingStrategy":"validation","validationCode":"// Control-plane side: confirm the Any unpacks as Address before sending\ntry {\n  any.unpack(io.envoyproxy.envoy.config.core.v3.Address.class);\n} catch (InvalidProtocolBufferException e) {\n  throw new IllegalStateException(\"Invalid Resource in address proto: \" + any.getTypeUrl(), e);\n}","typeGuard":"boolean isValidAddressAny(com.google.protobuf.Any any) {\n  try {\n    any.unpack(io.envoyproxy.envoy.config.core.v3.Address.class);\n    return true;\n  } catch (InvalidProtocolBufferException e) {\n    return false;\n  }\n}","tryCatchPattern":"// Client side: surface the NACK with the address-proto cause\n@Override public void onError(Status error) {\n  if (error.getDescription().contains(\"Invalid Resource in address proto\")) {\n    logger.log(WARNING, \"Unpackable Address Any in resource: \" + error.getDescription());\n  }\n}","preventionTips":["Always pack Address messages with Any.pack(address) so type_url is correct","Keep envoy proto versions aligned between control plane and client","Regenerate test fixtures instead of hand-editing serialized bytes","Log Any.type_url on the server before pushing resources"],"tags":["grpc","xds","protobuf","eds","any-unpack"],"backgroundTag":"protobuf-unmarshal-failed","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"}