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

protoc-gen-swagger: Fix message recursion detection #1437

Merged
merged 1 commit into from Jun 4, 2020
Merged

protoc-gen-swagger: Fix message recursion detection #1437

merged 1 commit into from Jun 4, 2020

Conversation

doyleish
Copy link
Contributor

@doyleish doyleish commented Jun 4, 2020

  • Fixes a bug introduced during 9e25b2b which added recursion
    detection within messages. Briefly, the nature of the bug was that
    references to messages not in the current recursion traversal were
    remaining in the map used to track those occurrences.
  • Includes a test case outlining the edge case that prompted this fix.

References to other Issues or PRs

Have you read the Contributing Guidelines?

Brief description of what is fixed or changed

Briefly, the nature of the bug was that references to messages not in the current recursion traversal path were remaining in the map used to track those occurrences. The fix just ensures those references don't hang around while recursing and are passed by value only.

Other comments

Testing the new case before fix...

(protoc-gen-swagger:)[16:32] ryan@psyduck ✘+ */grpc-gateway/protoc-gen-swagger $> go test ./genswagger/                                                                     
--- FAIL: TestMessageToQueryParametersNoRecursive (0.00s)
    template_test.go:518: No recursion error should be thrown: Recursive types are not allowed for query parameters, cycle found on ".example.NonRecursiveMessage"

And after the fix...

[1](protoc-gen-swagger:)[16:32] ryan@psyduck ✘+ */grpc-gateway/protoc-gen-swagger $> go test ./genswagger/
ok      github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger    0.005s

- Fixes a bug introduced during 9e25b2b which introduced recursion
  detection within messages. Briefly, the nature of the bug was that
  references to messages not in the current recursion traversal were
  remaining in the map used to track those occurrences.
- Includes a test case outlining the edge case that prompted this fix.
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@doyleish
Copy link
Contributor Author

doyleish commented Jun 4, 2020

@googlebot I fixed it.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels Jun 4, 2020
Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant! This looks great, sorry for the inconvenience.

@johanbrandhorst
Copy link
Collaborator

Fuzzit is being flukey, I'll override it

@johanbrandhorst johanbrandhorst merged commit 6dd8bd6 into grpc-ecosystem:master Jun 4, 2020
@johanbrandhorst
Copy link
Collaborator

Thanks for your contribution! Could you please cherry pick this against v2?

@doyleish
Copy link
Contributor Author

doyleish commented Jun 4, 2020

Thanks @johanbrandhorst for the merge!
I've created #1439 cherry-picking this to v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants