grpcServerCompatible writes out proto package instead of java package for request/response types
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
I'm not sure if this is an expected tighter limitation of the grpcServerCompatible = true option.
Given the following example where gRPC req/resp types have a different proto and java package, the generated code has the wrong package and fails to build.
// xyz/abc/api/GetConfigProto.proto
syntax = "proto3";
package xyz.abc.api;
option java_package = "xyz.abc.protos.api";
message GetConfigRequest {
string token = 1;
}
message GetConfigResponse {
string status = 1;
}
// xyz/abc/service/ServiceProto.proto
syntax = "proto3";
package xyz.abc.service;
option java_package = "xyz.abc.protos.service";
import "xyz/abc/api/GetConfigProto.proto";
service InternalService {
rpc GetConfigRequest(xyz.abc.protos.api.GetConfigRequest) returns (xyz.abc.protos.api.GetConfigResponse) {}
}
// generated/source/wire/xyz/abc/protos/service/InternalServiceWireGrpc.kt
...
import xyz.abc.protos.api.GetConfigRequest
import xyz.abc.protos.api.GetConfigResponse
public object InternalServiceWireGrpc {
public val SERVICE_NAME: String = "xyz.abc.service.InternalService"
...
public class InternalServiceBlockingStub : AbstractStub<InternalServiceStub> {
internal constructor(channel: Channel) : super(channel)
internal constructor(channel: Channel, callOptions: CallOptions) : super(channel, callOptions)
public override fun build(channel: Channel, callOptions: CallOptions) =
InternalServiceStub(channel, callOptions)
public fun GetCrawlerBatchConfig(request: xyz.abc.api.GetConfigRequest):
xyz.abc.api.GetConfigResponse = blockingUnaryCall(channel,
getGetCrawlerBatchConfigMethod(), callOptions, request)
}
}
Notably in the generated code, the xyz.abc.api.GetConfigRequest and xyz.abc.api.GetConfigResponse fully qualified types fail to Kotlin compile because the generated code is using the proto package and not the java package.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with xyz/abc/api/GetConfigProto.proto and xyz/abc/service/ServiceProto.proto, then inspect generation for grpcServerCompatible=true and the resulting InternalServiceWireGrpc.kt. Verify how request and response types are resolved when proto and java_package differ. Done means the generated fully qualified types use xyz.abc.protos.api and the example compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100