Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Kotlin Code References Non-Existent Message Instead of Outer Class #378

Open
akosyakov opened this issue Jan 29, 2025 · 2 comments

Comments

@akosyakov
Copy link

Description

When using the buf.build/connectrpc/kotlin plugin, if a service and a nested message inside a response share the same name (e.g., MytestService and ListMytestsResponse.Mytest), the generated ServiceClient and ServiceClientInterface incorrectly reference the nested message type directly instead of using the expected outer class (MytestOuterClass). This results in compilation errors because the referenced type does not exist.

Steps to Reproduce

  1. Define the following .proto file:
syntax = "proto3";

package myorg.v1;

service MytestService {
  rpc ListMytests(ListMytestsRequest) returns (ListMytestsResponse) {}
}

message ListMytestsRequest {}

message ListMytestsResponse {
  message Mytest {}

  repeated Mytest tests = 2;
}
  1. Use the following buf.gen.yaml:
version: v1
plugins:
  - plugin: buf.build/protocolbuffers/java
    out: ../java/src/main/java
  - plugin: buf.build/connectrpc/kotlin
    out: ../java/src/main/java
  1. Run Buf code generation.

The generated Kotlin code for MytestServiceClient and MytestServiceClientInterface references Mytest, which does not exist, instead of MytestOuterClass.

@jhump
Copy link
Member

jhump commented Jan 29, 2025

@akosyakov, is the name of the file mytest.proto? If not, please provide that, too.

Also, is that the entirety of the input proto source and the buf.gen.yaml? I just want to confirm there are no file options or managed mode config, missing from the examples above, that might impact code gen.

@jhump
Copy link
Member

jhump commented Jan 29, 2025

Also, it's not clear why the MytestServiceClientInterface would reference the Mytest message at all, since the request and response types point to ListMytestsRequest and ListsMytestsResponse, not to Mytest. Maybe you could also provide a snippet of the actual generated code that is causing problems as well as the actual error output of the compiler?

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

No branches or pull requests

2 participants