This is an automated email from the ASF dual-hosted git repository.

AlexStocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new 0d9761323 fix(triple): skip unsupported compat trailer attachments 
(#3418)
0d9761323 is described below

commit 0d97613232c3936d20d31c86e83fe969b5509be0
Author: 吴杨帆 <[email protected]>
AuthorDate: Thu Jun 18 19:39:26 2026 +0800

    fix(triple): skip unsupported compat trailer attachments (#3418)
    
    * fix(triple): skip unsupported compat trailer attachments
    
    * test(triple): format compat attachment test imports
    
    * test(triple): satisfy compat attachment lint
---
 protocol/triple/triple_protocol/handler_compat.go  |  3 +-
 .../triple/triple_protocol/handler_compat_test.go  | 32 ++++++++++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/protocol/triple/triple_protocol/handler_compat.go 
b/protocol/triple/triple_protocol/handler_compat.go
index 836dbcae6..b618d40ba 100644
--- a/protocol/triple/triple_protocol/handler_compat.go
+++ b/protocol/triple/triple_protocol/handler_compat.go
@@ -20,7 +20,6 @@ package triple_protocol
 import (
        "context"
        "errors"
-       "fmt"
        "net/http"
 )
 
@@ -88,7 +87,7 @@ func (t *tripleCompatInterceptor) 
compatUnaryServerInterceptor(ctx context.Conte
                        case []string:
                                trailer[key] = valRaw
                        default:
-                               panic(fmt.Sprintf("unsupported attachment value 
type %T", valRaw))
+                               logger.Warnf("[Triple][Handler] procedure %s 
skips unsupported trailer attachment %s with value type %T", t.procedure, key, 
valRaw)
                        }
                }
                resp.trailer = trailer
diff --git a/protocol/triple/triple_protocol/handler_compat_test.go 
b/protocol/triple/triple_protocol/handler_compat_test.go
index 93339f3af..f74296285 100644
--- a/protocol/triple/triple_protocol/handler_compat_test.go
+++ b/protocol/triple/triple_protocol/handler_compat_test.go
@@ -18,6 +18,7 @@
 package triple_protocol
 
 import (
+       "context"
        "testing"
 )
 
@@ -26,6 +27,11 @@ import (
        "github.com/dubbogo/grpc-go/status"
 
        "github.com/stretchr/testify/assert"
+       "github.com/stretchr/testify/require"
+)
+
+import (
+       "dubbo.apache.org/dubbo-go/v3/protocol/result"
 )
 
 func TestCompatError(t *testing.T) {
@@ -36,3 +42,29 @@ func TestCompatError(t *testing.T) {
        assert.Equal(t, "user defined", triErr.Message())
        assert.Len(t, triErr.Details(), 1)
 }
+
+func TestCompatUnaryServerInterceptorSkipsUnsupportedAttachmentValue(t 
*testing.T) {
+       t.Parallel()
+
+       interceptor := &tripleCompatInterceptor{procedure: 
"test.Service/Method"}
+       respRaw, err := interceptor.compatUnaryServerInterceptor(
+               context.Background(),
+               "request",
+               nil,
+               func(context.Context, any) (any, error) {
+                       rpcResult := &result.RPCResult{Rest: "response"}
+                       rpcResult.SetAttachments(map[string]any{
+                               "String-Value": "ok",
+                               "List-Value":   []string{"a", "b"},
+                               "Bool-Value":   true,
+                       })
+                       return rpcResult, nil
+               },
+       )
+
+       require.NoError(t, err)
+       resp := respRaw.(*Response)
+       assert.Equal(t, []string{"ok"}, resp.Trailer().Values("String-Value"))
+       assert.Equal(t, []string{"a", "b"}, resp.Trailer().Values("List-Value"))
+       assert.Empty(t, resp.Trailer().Values("Bool-Value"))
+}

Reply via email to