Allow buf curl to use multiple schemas when resolving elements #2587
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This enables the use of multiple
--schema
flags, and it also enables using both--reflect
and--schema
. By default, if a--schema
flag is present, reflection is not used. But if one also explicitly specifies--reflect
, then both will be used.The value is that sometimes an RPC response may include extensions or messages inside
google.protobuf.Any
values that are not defined in the same schema that defines the RPC service. For reflection, this is usually less of an issue. But it can still be an issue if the RPC server also does not know about an extension or message inside anAny
, which can happen when the data actually originates in some other server before being returned by the RPC handling server.When not using reflection, the value is even greater, since it is quite common for extensions or error details to be defined in separate modules. Sometimes they are defined in dependencies of the RPC schema, but if the RPC schema doesn't directly import the files in question, they may be omitted (since downloading a module only includes the files in dependencies that are necessary to compile).
This addresses an issue raised in Slack:
https://bufbuild.slack.com/archives/CRZ680FUH/p1699560915612389
The user was using the reflection endpoint to download descriptors. However, the reflection endpoint schema does not know about any custom options that the user has defined. So the way for custom options to be "known" and included in the JSON representation of the response is to actually point
buf curl
at both schemas: the reflection module (which defines the RPC endpoint) and another (which defines the custom options).So, without this change, we could only specify a single schema:
In the output of the above commands, all of the method options look like so:
And if we use
-v
and also have #2586 applied, we see that it prints the following:So, with this branch, we can actually point buf at two schemas, including the one that defines the relevant custom options:
And now we see the output includes method options that look like so: