Skip to content

feat: add variadic RPC warnings and checks#3294

Open
mochengqian wants to merge 2 commits intoapache:developfrom
mochengqian:fix/generic-variadic-support
Open

feat: add variadic RPC warnings and checks#3294
mochengqian wants to merge 2 commits intoapache:developfrom
mochengqian:fix/generic-variadic-support

Conversation

@mochengqian
Copy link
Copy Markdown
Contributor

@mochengqian mochengqian commented Apr 14, 2026

Description

Fixes #3286(issue)

Background

Issue #3259 exposed a real interoperability problem around variadic Go RPC methods such as args ...string when they are used from generic invocation or cross-language scenarios.

PR #3284 already addressed the short-term runtime compatibility path. This PR focuses on the long-term guidance side, so we can keep existing services compatible while discouraging new risky contracts from being introduced.

The goal of this PR is not to hinder existing users or further tighten runtime behavior, but to identify risks as early as possible and provide a clearer migration path for new cross-language services.

What this PR does

This PR adds non-breaking guidance in three places:

  • Emit a registration-time warning when a service exports variadic RPC methods.
  • Add a lightweight variadicrpccheck tool to detect exported variadic RPC contracts in CI or local development.

Runtime guidance

A reusable helper was added in common/rpc_service.go to detect variadic RPC methods based on the existing suiteMethod export rules. This keeps the detection logic aligned with what Dubbo-go actually treats as exported RPC methods.

During service registration, server/server.go now emits a warning if the service exposes variadic RPC methods. The warning is non-blocking and explicitly says:

  • existing variadic services remain supported
  • new cross-language or generic contracts should avoid ...T
  • []T, request structs, or Triple + Protobuf IDL are preferred for new contracts

This warning path is shared by Register(...), RegisterService(...), and generated Register<Service>Handler(...) flows through the same registration path.

Tooling guidance

This PR adds tools/variadicrpccheck, a warning-only scanner built on go/packages + AST/type information.

It scans exported service interfaces and exported service implementations for variadic RPC-style signatures, and prints file/line warnings with migration guidance.

A few guardrails are included to keep the first version practical:

  • skip *_test.go
  • skip *.pb.go
  • skip *.triple.go
  • filter out option-style variadics such as opts ...Option

The tool is wired into make rpc-contract-check and added to GitHub Actions after lint. It is guidance-only and always exits with 0, so it will not block CI.

Checklist

  • I confirm the target branch is develop
  • Code has passed local testing
  • I have added tests that prove my fix is effective or that my feature works

@mochengqian
Copy link
Copy Markdown
Contributor Author

I need a guidance : I haven't found a suitable way to add migration guidelines for the new cross-language service.

The specific content of the migration guidelines is as follows:

1.Recommend []T instead of ...T for interface-based definitions.
2.Recommend request/response structs for more complex inputs.
3.Recommend Triple + Protobuf IDL for new cross-language services.

@mochengqian mochengqian marked this pull request as draft April 14, 2026 12:22
@mochengqian mochengqian marked this pull request as ready for review April 14, 2026 13:25
@sonarqubecloud
Copy link
Copy Markdown

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.08306% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.21%. Comparing base (60d1c2a) to head (9b6d1e6).
⚠️ Report is 770 commits behind head on develop.

Files with missing lines Patch % Lines
tools/variadicrpccheck/scan.go 75.93% 44 Missing and 20 partials ⚠️
common/rpc_service.go 57.14% 9 Missing ⚠️
tools/variadicrpccheck/main.go 77.77% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3294      +/-   ##
===========================================
+ Coverage    46.76%   50.21%   +3.45%     
===========================================
  Files          295      486     +191     
  Lines        17172    36435   +19263     
===========================================
+ Hits          8031    18297   +10266     
- Misses        8287    16682    +8395     
- Partials       854     1456     +602     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants