Skip to content

fix(goctl): include nested client aliases#5627

Merged
kevwan merged 3 commits into
zeromicro:masterfrom
puneetdixit200:fix-rpc-client-transitive-aliases
Jun 27, 2026
Merged

fix(goctl): include nested client aliases#5627
kevwan merged 3 commits into
zeromicro:masterfrom
puneetdixit200:fix-rpc-client-transitive-aliases

Conversation

@puneetdixit200

Copy link
Copy Markdown
Contributor

Fixes #5618

This updates multi-service RPC client generation so per-service aliases still stay scoped to the service, but also include same-file message types referenced by that service's request/response messages.

The regression test extends the existing per-service alias coverage with a response message that contains an item type, and verifies only the owning service client exports that item alias.

Tests:

  • go test ./rpc/generator -run TestGenCallGroup_OnlyUsedTypesAliased -count=1
  • go test ./rpc/generator -count=1
  • go test ./rpc/... -count=1
  • git diff --check

@kevwan kevwan force-pushed the fix-rpc-client-transitive-aliases branch from fc9b29a to b19df40 Compare June 27, 2026 15:16
kevwan and others added 2 commits June 28, 2026 00:01
In v1.10.1 the per-service alias filter introduced by zeromicro#5482 only collected
direct RequestType/ReturnsType names.  Message types referenced by fields
inside those request/response messages (e.g. a repeated item type inside a
response) were silently dropped, breaking callers that used the generated
type aliases after upgrading.

Fix: replace the flat two-type collect with collectServiceUsedTypes, which
does a recursive DFS over the proto message graph so all transitively-
referenced same-file message types are aliased in the generated client file.
The per-service scope (cross-service isolation) is fully preserved.

Fixes zeromicro#5618

Tests added:
- 7 unit tests for collectServiceUsedTypes covering: direct-only, NormalField,
  MapField value type, Oneof fields, multi-level transitive chain, cycle
  detection, and cross-service exclusion
- 4 integration tests via genCallGroup covering: NormalField + cross-service
  isolation, MapField, Oneof, and multi-level transitive chain

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add coverage for transitive alias collection across normal fields, map
value types, oneof branches, multi-level dependencies, cycle handling,
and cross-service isolation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kevwan kevwan added this pull request to the merge queue Jun 27, 2026
Merged via the queue into zeromicro:master with commit f910257 Jun 27, 2026
6 checks passed
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.

goctl v1.10.1 does not generate client aliases for nested message types used by service responses

2 participants