]> git.feebdaed.xyz Git - 0xmirror/grpc-go.git/commitdiff
xdsclient: typed config better nil checks (#8412)
authorBurkov Egor <xwooffie@gmail.com>
Fri, 18 Jul 2025 15:20:15 +0000 (18:20 +0300)
committerGitHub <noreply@github.com>
Fri, 18 Jul 2025 15:20:15 +0000 (08:20 -0700)
xds/internal/xdsclient/xdsresource/filter_chain.go
xds/internal/xdsclient/xdsresource/filter_chain_test.go
xds/internal/xdsclient/xdsresource/unmarshal_cds.go
xds/internal/xdsclient/xdsresource/unmarshal_lds_test.go

index 3945199133ec995d30d7ed2899d9df21b5446773..46bbcaf4a1f28a0c6c7abccbb8a7a21b3bb05d58 100644 (file)
@@ -542,8 +542,8 @@ func (fcm *FilterChainManager) filterChainFromProto(fc *v3listenerpb.FilterChain
                return nil, fmt.Errorf("transport_socket field has unexpected name: %s", name)
        }
        tc := ts.GetTypedConfig()
-       if tc == nil || tc.TypeUrl != version.V3DownstreamTLSContextURL {
-               return nil, fmt.Errorf("transport_socket field has unexpected typeURL: %s", tc.TypeUrl)
+       if typeURL := tc.GetTypeUrl(); typeURL != version.V3DownstreamTLSContextURL {
+               return nil, fmt.Errorf("transport_socket missing typed_config or wrong type_url: %q", typeURL)
        }
        downstreamCtx := &v3tlspb.DownstreamTlsContext{}
        if err := proto.Unmarshal(tc.GetValue(), downstreamCtx); err != nil {
index bc4cd8205e3ff90165c1bcaadfc513f0d064d222..67b37dffb83608c0221003ec6ed64c6f5efe6d5c 100644 (file)
@@ -348,7 +348,7 @@ func (s) TestNewFilterChainImpl_Failure_BadSecurityConfig(t *testing.T) {
                                        },
                                },
                        },
-                       wantErr: "transport_socket field has unexpected typeURL",
+                       wantErr: fmt.Sprintf("transport_socket missing typed_config or wrong type_url: \"%s\"", testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{}).TypeUrl),
                },
                {
                        desc: "badly marshaled transport socket",
index c2ced0d6203f738fef9bd40b3ced36d7cbd5a93b..43247c5b8d9fe6fb798afebc8a8b86789f244eb7 100644 (file)
@@ -287,8 +287,8 @@ func securityConfigFromCluster(cluster *v3clusterpb.Cluster) (*SecurityConfig, e
                return nil, fmt.Errorf("transport_socket field has unexpected name: %s", name)
        }
        tc := ts.GetTypedConfig()
-       if tc == nil || tc.TypeUrl != version.V3UpstreamTLSContextURL {
-               return nil, fmt.Errorf("transport_socket field has unexpected typeURL: %s", tc.TypeUrl)
+       if typeURL := tc.GetTypeUrl(); typeURL != version.V3UpstreamTLSContextURL {
+               return nil, fmt.Errorf("transport_socket missing typed_config or wrong type_url: %q", typeURL)
        }
        upstreamCtx := &v3tlspb.UpstreamTlsContext{}
        if err := proto.Unmarshal(tc.GetValue(), upstreamCtx); err != nil {
index 71eaed058b088655640ae75ba2e225f5fecae11c..900afdd311b00d4c11118bb3abb9ada82324cd00 100644 (file)
@@ -1266,7 +1266,7 @@ func (s) TestUnmarshalListener_ServerSide(t *testing.T) {
                                },
                        }),
                        wantName: v3LDSTarget,
-                       wantErr:  "transport_socket field has unexpected typeURL",
+                       wantErr:  fmt.Sprintf("transport_socket missing typed_config or wrong type_url: \"%s\"", testutils.MarshalAny(t, &v3tlspb.UpstreamTlsContext{}).TypeUrl),
                },
                {
                        name: "badly marshaled transport socket",