AlexStocks commented on code in PR #3500:
URL: https://github.com/apache/dubbo-go/pull/3500#discussion_r3642572646


##########
internal/config.go:
##########
@@ -215,3 +215,34 @@ func ValidateRegistryIDs(ids []string, regs 
map[string]*global.RegistryConfig) e
        }
        return nil
 }
+
+// IsGenericMode reports whether a generic value denotes a generic call. It is 
the
+// single source of truth for the accepted generic modes so that callers 
(config
+// validation, protocol-level routing) stay in sync instead of each 
maintaining its
+// own list. An empty value means the call is not generic.
+//
+// Recognized modes: "true" (Map, default), "gson", "protobuf-json", "bean", 
and the
+// legacy "protobuf" (kept for compatibility, not recommended).
+func IsGenericMode(generic string) bool {
+       if generic == "" {
+               return false
+       }
+       return strings.EqualFold(generic, constant.GenericSerializationDefault) 
||
+               strings.EqualFold(generic, constant.GenericSerializationGson) ||
+               strings.EqualFold(generic, 
constant.GenericSerializationProtobufJson) ||
+               strings.EqualFold(generic, constant.GenericSerializationBean) ||
+               strings.EqualFold(generic, 
constant.GenericSerializationProtobuf)
+}
+
+// ValidateGenericType validates the generic serialization type (generic mode).
+// An empty value means the call is not generic and is allowed. Unknown values 
fail
+// fast instead of silently falling back to the Map generalizer.
+//
+// Valid values: "true" (Map, default), "gson", "protobuf-json", "bean".
+// "protobuf" is kept as a legacy compatibility value and is not recommended.
+func ValidateGenericType(generic string) error {
+       if generic == "" || IsGenericMode(generic) {
+               return nil
+       }
+       return fmt.Errorf("invalid generic type %q, valid values: true, gson, 
protobuf-json, bean", generic)

Review Comment:
   [P2] 错误信息应列出函数实际接受的值
   
   当前函数还接受空字符串(非 generic)和 legacy `protobuf`,但错误文本只列出 
`true/gson/protobuf-json/bean`。这会让用户按错误提示排查时看不到两个真实合法分支。请在消息中补充 
`protobuf`,并说明空字符串表示非 generic 调用。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to