grpc / grpc/grpc-dotnet

GrpcChannel rewrites path with method.FullName

Open
#2,660 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
4.5k
Forks
835
Avg merge
6d 3h
Merged PRs (30d)
7

Description

### What version of gRPC and what language are you using?

I'm using .NET 9 C# 14 with gRPC lib: `Grpc.Net.Client` version `2.70.0`

### What operating system (Linux, Windows,...) and version?

Windows 11 Pro

### What runtime / compiler are you using (e.g. .NET Core SDK version `dotnet --info`)

```
.NET SDK:
Version: 9.0.304
Commit: f12f5f689e
Workload version: 9.0.300-manifests.407ced12
MSBuild version: 17.14.16+5d8159c5f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.304\

.NET workloads installed:
[maui]
Installation Source: SDK 9.0.300
Manifest Version: 9.0.82/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maui\9.0.82\WorkloadManifest.json
Install Type: Msi

Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.8
Architecture: x64
Commit: aae90fa090

.NET SDKs installed:
5.0.416 [C:\Program Files\dotnet\sdk]
6.0.428 [C:\Program Files\dotnet\sdk]
8.0.119 [C:\Program Files\dotnet\sdk]
9.0.106 [C:\Program Files\dotnet\sdk]
9.0.109 [C:\Program Files\dotnet\sdk]
9.0.304 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download
```

### What did you do?

My case is doing gRPC request to the backend service __through proxy__.

I'm making `GrpcChannel` like this:
```
GrpcChannel.ForAddress("https://:/backend/");
```

Part `/backend/` is required cause that's nginx rule mapping service by its name. So, making proxy call to `https://proxy:5555/backend/service/v1.Service/Method` I'm really doing call to `https://service:5555/v1.Service/Method`.

### What did you expect to see?

Not rewriting proxy-path or an option to prepend it to `method.FullName`

### What did you see instead?

So what's wrong?

In this code segment:
https://github.com/grpc/grpc-dotnet/blob/f4148e8833dcedf8ef13b0817c0fc1c036921f7e/src/Grpc.Net.Client/GrpcChannel.cs#L583C1-L584C43

It rewrites my proxy path `/backend/service` just to `/v1.Service/Method`

Image

### Anything else we should know about your project / environment?

Contributor guide

Open the contributing guide

Research direction

Start at src/Grpc.Net.Client/GrpcChannel.cs around lines 583-584 and reproduce the request construction with a base address containing /backend/service. Confirm the expected behavior for proxy paths, then verify that the generated request preserves the configured path or provides a supported way to prepend it to method.FullName.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, grpc, nginx
Domain
api, backend, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.