@@ -253,13 +253,17 @@ func decodeResponse(opts *DecodeOptions, rType *ResourceType, resp response) (ma
253
253
perResourceErrors := make (map [string ]error ) // Tracks resource validation errors, where we have a resource name.
254
254
ret := make (map [string ]dataAndErrTuple ) // Return result, a map from resource name to either resource data or error.
255
255
for _ , r := range resp .resources {
256
- r , err := xdsresource .UnwrapResource (r )
256
+ // Unwrap and validate the resource, but preserve the original bytes for
257
+ // decoding. This is required for resource types that don't have a name
258
+ // field in the resource itself, but only have one in the wrapped
259
+ // resource.
260
+ inner , err := xdsresource .UnwrapResource (r )
257
261
if err != nil {
258
262
topLevelErrors = append (topLevelErrors , err )
259
263
continue
260
264
}
261
- if _ , ok := opts .Config .ResourceTypes [r . TypeUrl ]; ! ok || r . TypeUrl != resp .typeURL {
262
- topLevelErrors = append (topLevelErrors , xdsresource .NewErrorf (xdsresource .ErrorTypeResourceTypeUnsupported , "unexpected resource type: %q " , r .GetTypeUrl ()))
265
+ if _ , ok := opts .Config .ResourceTypes [inner . GetTypeUrl () ]; ! ok || inner . GetTypeUrl () != resp .typeURL {
266
+ topLevelErrors = append (topLevelErrors , xdsresource .NewErrorf (xdsresource .ErrorTypeResourceTypeUnsupported , "unexpected resource type: %q " , inner .GetTypeUrl ()))
263
267
continue
264
268
}
265
269
result , err := rType .Decoder .Decode (r .GetValue (), * opts )
0 commit comments