fix: rendering mock values for recursive messages no longer crashes by software-dov · Pull Request #587 · googleapis/gapic-generator-python · GitHub
Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

fix: rendering mock values for recursive messages no longer crashes#587

Merged
software-dov merged 3 commits into
googleapis:masterfrom
software-dov:recursive-mock
Sep 3, 2020
Merged

fix: rendering mock values for recursive messages no longer crashes#587
software-dov merged 3 commits into
googleapis:masterfrom
software-dov:recursive-mock

Conversation

@software-dov

@software-dov software-dov commented Sep 3, 2020

Copy link
Copy Markdown
Contributor

Protobuf allows recursive message types, i.e. messages whose fields
are of the same type as the message itself.

message Foo {
    Foo foo = 1; // Degenerate case
}

A real world example is bigquery.v2.data:RowFilter

These recursive types cause a problem when trying to render
mock values for unit tests because there's no inherent limit on
when to stop rendering nested values.
The solution in this commit is an artifical cap on the depth of
recursion in rendering mock values.

Protobuf allows recursive message types, i.e. messages whose fields
are of the same type as the message itself.

message Foo {
    Foo foo = 1; // Degenerate case
}

A real world example is bigquery.v2.data:RowFilter

The solution in this commit is an artifical cap on the depth of
recursion in rendering mock values.
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 3, 2020
@codecov

codecov Bot commented Sep 3, 2020

Copy link
Copy Markdown

@busunkim96

Copy link
Copy Markdown
Contributor

Does it make sense to add a message like this to https://github.com/googleapis/gapic-showcase?

@software-dov

Copy link
Copy Markdown
Contributor Author

It definitely sounds like a good idea to add a recursive showcase message type. I'll file an issue there.

@software-dov

Copy link
Copy Markdown
Contributor Author

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants