-
Notifications
You must be signed in to change notification settings - Fork 49
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
IAM Policy Mixin for HttpJson matches incorrect Mux Handler #1338
Comments
@noahdietz Would you be fine with me changing the order of |
Yeah I think that's fine, but kind of papers over the actual issue which is we have greedy path matchers. This could happen again for a different case. Specifically, Worst case, we go with the ordering-based fix. Great analysis btw, thanks. |
Ah sure, good idea! I think I can make the changes to how it set the values in the template: gapic-showcase/util/genrest/resttools/constants.go Lines 26 to 34 in 082b527
to be
which should only match for alphanumerics + dash + underscore (for single segments) and + slash for (multi segments). Running this locally changes quite a bit of the handleFuncs, but the mixins look like:
Running this locally seems to work for the showcase tests. |
That looks accurate to me @vchudnov-g WDYT? good stuff @lqiu96 |
In terms of changing the regexes, the proposal looks fine, but are we sure those are all the characters allowed? They probably are, but part of me leans toward making more conservative changes first: |
That would be fine with me, perhaps even preferred. |
Ah my bad, I believe that is a typo. The test I'm trying to add exists in this PR (currently a draft testing things out): https://github.com/googleapis/sdk-platform-java/pull/1789/files#diff-6102ce1a55d25723b508257a0e715555e252ec608d718631c162414591c44cfaR172-R175. (Creating the user isn't needed -- I wasn't sure of the error for a few hours and was playing around) It's the second call |
In terms of allowed characters, if we were to go that route: maybe using In terms of multiple matchers: the first match wins, and if no HTTP method is specified, any method matches (as per gorilla/mux#480) |
Yep, that is the intended GET method. I created a PR with your suggestion of using the colon |
Showcase test makes a call to
getIamPolicy
RPC:GET http://localhost:7469/v1beta1/users/5da0e7e4:getIamPolicy
.The userId should be
users/5da0e7e4
, but the error message (A user with name users/5da0e7e4:getIamPolicy not found.
) suggests that the userId is matched asusers/5da0e7e4:getIamPolicy
Local Gapic Showcase Server Error:
It looks to have matched with this handleFunc:
gapic-showcase/server/genrest/genrest.go
Line 56 in 082b527
gapic-showcase/server/genrest/genrest.go
Line 105 in 082b527
Full Java Stacktrace:
Possible Fixes:
handleFunc RegExps match exact cases
I'm not sure this is something Mux supports. Online references seem to suggest fixing the ordering of the handleFuncs.
Move the Mixin handleFuncs to the top
Adding something like:
Seems to work
Adding something like:
solves the current issue, but may not cover every case.
The text was updated successfully, but these errors were encountered: