XiaoFeiASK opened a new pull request, #3501:
URL: https://github.com/apache/dubbo-go/pull/3501
### What this PR does
Part of #3472 (泛化调用优化).
This PR covers the `filter/generic` validation slice. Previously, some
generic call paths silently fell back to the Map generalizer when an unknown
generic mode was configured, which made configuration mistakes such as
`generic=bad-type` hard to diagnose.
This PR makes unsupported generic modes fail with a clear error in the
consumer/provider filter paths instead of continuing with the default Map mode.
### Changes
- **`filter/generic/util.go`**
- Change `getGeneralizer` to return `(Generalizer, error)`.
- Accept `true`, `gson`, `bean`, `protobuf-json`, and legacy `protobuf`.
- Return `unsupported generic mode` for unknown values.
- Add shared mode resolution for configured URL mode and invocation
attachment mode.
- **`filter/generic/filter.go`**
- Validate generic mode before rewriting consumer generic invocations.
- Propagate invalid mode errors instead of invoking with a fallback
generalizer.
- Keep `generic=false` and empty URL generic as pass-through behavior.
- Use the resolved generic mode when setting outgoing invocation
attachments.
- Validate generic mode before typed reply deserialization in `OnResponse`.
- **`filter/generic/service_filter.go`**
- Validate provider-side generic invocation mode before realizing
arguments.
- Return clear errors for unsupported modes.
- Validate generic mode before generalizing provider responses.
- **Tests**
- Cover unsupported generic modes.
- Cover `generic=false` and empty generic pass-through behavior.
- Cover invocation attachment override and invalid attachment rejection.
- Cover legacy `protobuf` as a supported compatibility value.
### Note for reviewers
This PR only handles the `filter/generic` strict-validation part of #3472.
Follow-up PRs will cover typed result behavior, `InvokeWithType` mode
awareness, Triple generic mode detection, and `GenericException` alias
exposure. The generic mode policy should stay aligned across `client`,
`filter/generic`, and `protocol/triple`.
### Verification
`go test ./filter/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]