fix(proto): correct code generation for google.protobuf.Empty (#3715) #3716
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…mpty(#3715)
Description (what this PR does / why we need it):
This PR fixes a bug in the kratos proto server command where it generates incorrect Go code when google.protobuf.Empty is used as a request or response type in an RPC method.
Previous Behavior:
The command would incorrectly generate types like *pb.google_protobuf_Empty, which do not exist and cause compilation errors.
Root Cause:
The bug was caused by the parametersName helper function in internal/proto/server/server.go. This function indiscriminately replaced all dots (.) with underscores (_) in parameter type names. This behavior incorrectly transformed the well-known type "google.protobuf.Empty" into "google_protobuf_Empty".
This PR's Fix:
This PR corrects the behavior by updating the parametersName function. It now includes a check to see if the input name is exactly "google.protobuf.Empty". If it is, the function returns the original string without modification. For all other type names, the existing replacement logic is preserved.
Which issue(s) this PR fixes (resolves / be part of):
fixes #3715
Other special notes for the reviewers: