fix: allow proto3 optional fields in path parameters by susanachl · Pull Request #6416 · grpc-ecosystem/grpc-gateway (original) (raw)

References to other Issues or PRs

Fixes #6352

Motivation & Context

This PR removes the compiler restriction (originally introduced in #1951) that prevents proto3 optional fields from being mapped to HTTP path parameters.

Addressing the Routing Ambiguity Concern:
By removing this check, we decouple the Protobuf schema validation from the HTTP routing layer. If an optional field is mapped to a path parameter like /owners/{owner_name}/pets/, the structural requirement of the URL template remains intact.

If a client omits the optional field, resulting in an empty path segment (POST /v1/owners//pets/fido:feed), the underlying gRPC-Gateway HTTP router will naturally fail to match the template and return a 404 Not Found. This correctly shifts the responsibility of validating path completeness from the proto compiler to the HTTP router, which is the expected behavior for malformed requests.

Changes