square / square/wire

GrpcClient.Builder's baseUrl path segments get ignored

Open
#2,730 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
4.4k
Forks
627
Avg merge
3d 15m
Merged PRs (30d)
20

Description

When using the compiler to generate a Kotlin client, the GrpcMethod.paths that are generated are absolute. For example /greeter.HelloService/SayHello. The GrpcClient.Builder takes a baseUrl, but since the paths are absolute, and path segments of the baseUrl are discarded when GrpcClient#newCall runs.

If the paths were relative, greeter.HelloService/SayHello (no leading slash), then the baseUrl containing path segments would work fine.

My use case is that I'm adding gRPC to an existing application, and am being asked to deploy it at a path like /appName/grpc/*.

My workaround is an OkHttp interceptor that rewrites the request URL to include the path components I need.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how GrpcClient.Builder's baseUrl is used in GrpcClient#newCall and how generated GrpcMethod.path values are formed by the compiler. Reproduce the absolute-path behavior with a baseUrl containing path segments, then verify that requests preserve those segments while continuing to target the generated gRPC method path.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.