Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLs using verb no longer work after upgrading to v1.5.0 #760

Closed
orjanbruland opened this issue Oct 1, 2018 · 3 comments
Closed

URLs using verb no longer work after upgrading to v1.5.0 #760

orjanbruland opened this issue Oct 1, 2018 · 3 comments
Assignees
Labels

Comments

@orjanbruland
Copy link

We tested out the latest 1.5.0 release and noticed it broke our URLs that use colons with a custom verb, like described here: https://cloud.google.com/apis/design/custom_methods

In our case we have a both a "Get" method and a custom method sharing parts of the URL, like this:

  rpc GetDevice(GetDeviceRequest) returns (Device) {
    option (google.api.http) = { get: "/v2/{name=projects/*/devices/*}" };
  }
  rpc StreamDevices(StreamDevicesRequest) returns (stream StreamDevicesResponse) {
      option (google.api.http) = { get: "/v2/{name=projects/*/devices/*}:stream" };
   }

When upgrading from v1.4.1 to v1.5.0 requests no longer seem to reach the StreamDevices method.

Steps you follow to reproduce the error:

By extending the TestMuxServeHTTP test with the following test-case, I'm able to trigger the same issue:

{
			patterns: []stubPattern{
				{
					method: "GET",
					ops:    []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1},
					pool:   []string{"foo", "id"},
				},
				{
					method: "GET",
					ops:    []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1},
					pool:   []string{"foo", "id"},
					verb:   "verb",
				},
			},
			reqMethod: "GET",
			reqPath:   "/foo/bar:verb",
			headers: map[string]string{
				"Content-Type": "application/json",
			},
			respStatus:  http.StatusOK,
			respContent: "GET /foo/{id=*}:verb",
		},

What did you expect to happen instead:

I would expect the test to reach the /foo/{id=*}:verb pattern, or in our case reach the StreamDevices method as in the previous releases.

What's your theory on why it isn't working:

It seems to be a side-effect of fixing #224.

@johanbrandhorst
Copy link
Collaborator

Argh, thanks for raising this issue! Terribly sorry to have broken your workflow. It looks like we have to revert #708, is that correct?

@orjanbruland
Copy link
Author

One solution could be to introduce a ServeMuxOption to allow Patterns created without a verb to match requests using a verb. This way, using colons in IDs is an opt-in feature instead of breaking backward compatibility.

@johanbrandhorst
Copy link
Collaborator

Yeah, backwards compatibility is paramount here, of course. It also seems like the wrong thing to support this tbh, I'm just disappointed we didn't discover it earlier and didn't break users. I'll see what some of the others think but we'll likely just revert #708 and continue the discussion in #224.

@johanbrandhorst johanbrandhorst self-assigned this Oct 1, 2018
johanbrandhorst added a commit that referenced this issue Oct 1, 2018
The solution for #224 turned out to break backwards
compatibility, so we're going to have to find another
solution for users who desire this behaviour.
Also adds test cases from #760.
achew22 pushed a commit that referenced this issue Oct 1, 2018
The solution for #224 turned out to break backwards
compatibility, so we're going to have to find another
solution for users who desire this behaviour.
Also adds test cases from #760.
adasari pushed a commit to adasari/grpc-gateway that referenced this issue Apr 9, 2020
The solution for grpc-ecosystem#224 turned out to break backwards
compatibility, so we're going to have to find another
solution for users who desire this behaviour.
Also adds test cases from grpc-ecosystem#760.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants