grpcreflect: add flag to make Client try to be lenient in the face of missing dependencies #604
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.
Ever since v1.15 was released, the
grpcreflect
package inadvertently became more strict:protoreflect
descriptors, which means creating descriptors uses the protobuf-go runtime'sprotodesc
package. That package is more strict and does more validation than this repo'sdesc
package.desc
package was doing enough validation to realize the descriptor was junk. But starting with v1.15, this would result in an error.So, if a file was imported only for custom options (for things like OpenAPI annotations, validation options, etc), it was previously allowed to be missing. But that is no longer the case.
This has actually caused some issues for users of
grpcurl
andgrpcui
, which use thegrpcreflect
package in this repo. See, for example, fullstorydev/grpcurl#423, fullstorydev/grpcurl#432, fullstorydev/grpcurl#451, and fullstorydev/grpcui#279.In these cases, prior to
grpcurl
pulling in v1.15 of this repo, things worked and the files that would later cause issues were effectively ignored (and okay to ignore because they were just providing custom options, not necessary for the descriptors to actually be linked). But since v1.15, they fail.This branch adds a new method to
*grpcreflect.Client
, allowing callers to opt-in to lenient behavior that will effectively ignore "file not found" errors when downloading the schema from the server. If the missing file is not actually necessary to link the descriptors, the client will not complain about the missing file and instead return the requested schema (though any custom options provided by the missing files will be uninterpretable).