ProtoBufMatcher not working when proto package name contains dots #581

Closed
opened 2025-12-29 15:27:34 +01:00 by adam · 2 comments
Owner

Originally created by @vgoranski on GitHub (Mar 6, 2024).

Describe the bug

When I'm trying to use the recently introduced ProtoBufMatcher with package in proto that contains dots in the name, I'm getting Grpc.Core.RpcException with message Status(StatusCode="Unimplemented", Detail="Bad gRPC response. HTTP status code: 404"). If I remove the dots everything works fine.

Expected behavior:

Package name containig dots works.

Test to reproduce

[Fact]
public async Task WireMockServer_WithBodyAsProtoBuf_InlineProtoDefinition_UsingGrpcGeneratedClient()
{
    const string packageName = "greet.foo";
    const string protoDefinition = $$"""

                                   syntax = "proto3";
                                   package {{packageName}};
                                   service Greeter {
                                     rpc SayHello (HelloRequest) returns (HelloReply);
                                   }
                                   message HelloRequest {
                                     string name = 1;
                                   }
                                   message HelloReply {
                                     string message = 1;
                                   }

                                   """;

    // Arrange
    using var server = WireMockServer.Start(useHttp2: true);

    var jsonMatcher = new JsonMatcher(new { name = "stef" });

    server
        .Given(Request.Create()
                      .UsingPost()
                      .WithPath($"/{packageName}.Greeter/SayHello")
                      .WithBodyAsProtoBuf(protoDefinition, $"{packageName}.HelloRequest", jsonMatcher)
        )
        .RespondWith(Response.Create()
                             .WithHeader("Content-Type", "application/grpc")
                             .WithTrailingHeader("grpc-status", "0")
                             .WithBodyAsProtoBuf(protoDefinition, $"{packageName}.HelloReply",
                                 new
                                 {
                                     message = "hello stef {{request.method}}"
                                 }
                             )
                             .WithTransformer()
        );

    // Act
    var channel = GrpcChannel.ForAddress(server.Url!);

    var client = new Greeter.GreeterClient(channel);

    var reply = await client.SayHelloAsync(new HelloRequest { Name = "stef" });

    // Assert
    reply.Message.Should().Be("hello stef POST");

    server.Stop();
}
Originally created by @vgoranski on GitHub (Mar 6, 2024). ### Describe the bug When I'm trying to use the recently introduced ProtoBufMatcher with package in proto that contains dots in the name, I'm getting `Grpc.Core.RpcException` with message `Status(StatusCode="Unimplemented", Detail="Bad gRPC response. HTTP status code: 404")`. If I remove the dots everything works fine. ### Expected behavior: Package name containig dots works. ### Test to reproduce ``` csharp [Fact] public async Task WireMockServer_WithBodyAsProtoBuf_InlineProtoDefinition_UsingGrpcGeneratedClient() { const string packageName = "greet.foo"; const string protoDefinition = $$""" syntax = "proto3"; package {{packageName}}; service Greeter { rpc SayHello (HelloRequest) returns (HelloReply); } message HelloRequest { string name = 1; } message HelloReply { string message = 1; } """; // Arrange using var server = WireMockServer.Start(useHttp2: true); var jsonMatcher = new JsonMatcher(new { name = "stef" }); server .Given(Request.Create() .UsingPost() .WithPath($"/{packageName}.Greeter/SayHello") .WithBodyAsProtoBuf(protoDefinition, $"{packageName}.HelloRequest", jsonMatcher) ) .RespondWith(Response.Create() .WithHeader("Content-Type", "application/grpc") .WithTrailingHeader("grpc-status", "0") .WithBodyAsProtoBuf(protoDefinition, $"{packageName}.HelloReply", new { message = "hello stef {{request.method}}" } ) .WithTransformer() ); // Act var channel = GrpcChannel.ForAddress(server.Url!); var client = new Greeter.GreeterClient(channel); var reply = await client.SayHelloAsync(new HelloRequest { Name = "stef" }); // Assert reply.Message.Should().Be("hello stef POST"); server.Stop(); } ```
adam added the bug label 2025-12-29 15:27:34 +01:00
adam closed this issue 2025-12-29 15:27:35 +01:00
Author
Owner

@StefH commented on GitHub (Mar 6, 2024):

@vgoranski Thank you for noticing, I'll fix this and release a new NuGet soon.

@StefH commented on GitHub (Mar 6, 2024): @vgoranski Thank you for noticing, I'll fix this and release a new NuGet soon.
Author
Owner

@StefH commented on GitHub (Mar 6, 2024):

#1078

@StefH commented on GitHub (Mar 6, 2024): #1078
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#581