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

lint: forbid gRPC Status.WithDetails() due to gogoproto issues #61617

Merged
merged 1 commit into from
Mar 8, 2021

Conversation

erikgrinaker
Copy link
Contributor

gRPC's Status.WithDetails() allows callers to attach
Protobuf-structured details to gRPC errors. Unfortunately, this does not
work with gogoproto types, since they're stored in an Any field
internally and gogo types are not registered in the standard Protobuf
type registry. Calling Details() with such a type will return an
unmarshalling error in place of the detail.

To avoid this problem, this patch adds a linter that disallows any use of
Status.WithDetails().

Note that there is a separate package github.com/gogo/status that
emulates the standard gRPC status package using gogoproto Protobufs
instead. However, due to the uncertain future of the gogoproto project
we are hesitant to introduce additional gogo dependencies.

Related to #56208 and cockroachdb/errors#63.

Release justification: non-production code changes
Release note: None

gRPC's `Status.WithDetails()` allows callers to attach
Protobuf-structured details to gRPC errors. Unfortunately, this does not
work with gogoproto types, since they're stored in an `Any` field
internally and gogo types are not registered in the standard Protobuf
type registry. Calling `Details()` with such a type will return an
unmarshalling error in place of the detail.

To avoid this problem, this patch adds a linter that disallows any use of
`Status.WithDetails()`.

Note that there is a separate package `github.com/gogo/status` that
emulates the standard gRPC `status` package using gogoproto Protobufs
instead. However, due to the uncertain future of the gogoproto project
we are hesitant to introduce additional gogo dependencies.

Release justification: non-production code changes
Release note: None
@erikgrinaker erikgrinaker requested a review from tbg March 8, 2021 15:07
@erikgrinaker erikgrinaker self-assigned this Mar 8, 2021
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@erikgrinaker
Copy link
Contributor Author

bors r=tbg

@craig
Copy link
Contributor

craig bot commented Mar 8, 2021

Build succeeded:

@craig craig bot merged commit 8b8c6b0 into cockroachdb:master Mar 8, 2021
erikgrinaker added a commit to erikgrinaker/errors that referenced this pull request Mar 8, 2021
This patch adds support for automatic en/decoding of gRPC `Status`
errors, enabled by importing the `extgrpc` package. It supports statuses
generated both by the standard `google.golang.org/grpc/status` and the
gogoproto-based `github.com/gogo/status` packages.

Encoded statuses are always represented as `gogo/status`-based `Status`
Protobufs, since the `EncodedError` type is a gogoproto type using an
`Any` field for structured errors, and only gogoproto types can be
placed here since standard Protobufs are not registered in the gogoproto
type registry.

Note that to preserve error details, gogo-based `Status` objects with
gogo-based details must be used, otherwise details may not be preserved.
This is for similar reasons as outlined above, and is a limitation in
the gRPC package -- see code comments for further details. A CRDB linter
rule forbidding use of `Status.WithDetails()` was submitted in
cockroachdb/cockroach#61617.
@erikgrinaker erikgrinaker deleted the lint-grpc-details branch March 8, 2021 17:55
erikgrinaker added a commit to erikgrinaker/errors that referenced this pull request Mar 9, 2021
This patch adds support for automatic en/decoding of gRPC `Status`
errors, enabled by importing the `extgrpc` package. It supports statuses
generated both by the standard `google.golang.org/grpc/status` and the
gogoproto-based `github.com/gogo/status` packages.

Encoded statuses are always represented as `gogo/status`-based `Status`
Protobufs, since the `EncodedError` type is a gogoproto type using an
`Any` field for structured errors, and only gogoproto types can be
placed here since standard Protobufs are not registered in the gogoproto
type registry.

Note that to preserve error details, gogo-based `Status` objects with
gogo-based details must be used, otherwise details may not be preserved.
This is for similar reasons as outlined above, and is a limitation in
the gRPC package -- see code comments for further details. A CRDB linter
rule forbidding use of `Status.WithDetails()` was submitted in
cockroachdb/cockroach#61617.
erikgrinaker added a commit to erikgrinaker/errors that referenced this pull request Mar 10, 2021
This patch adds support for automatic en/decoding of gRPC `Status`
errors, enabled by importing the `extgrpc` package. It supports statuses
generated both by the standard `google.golang.org/grpc/status` and the
gogoproto-based `github.com/gogo/status` packages.

Encoded statuses are always represented as `gogo/status`-based `Status`
Protobufs, since the `EncodedError` type is a gogoproto type using an
`Any` field for structured errors, and only gogoproto types can be
placed here since standard Protobufs are not registered in the gogoproto
type registry.

Note that to preserve error details, gogo-based `Status` objects with
gogo-based details must be used, otherwise details may not be preserved.
This is for similar reasons as outlined above, and is a limitation in
the gRPC package -- see code comments for further details. A CRDB linter
rule forbidding use of `Status.WithDetails()` was submitted in
cockroachdb/cockroach#61617.
erikgrinaker added a commit to erikgrinaker/errors that referenced this pull request Mar 14, 2021
This patch adds support for automatic en/decoding of gRPC `Status`
errors, enabled by importing the `extgrpc` package. It supports statuses
generated both by the standard `google.golang.org/grpc/status` and the
gogoproto-based `github.com/gogo/status` packages.

Encoded statuses are always represented as `gogo/status`-based `Status`
Protobufs, since the `EncodedError` type is a gogoproto type using an
`Any` field for structured errors, and only gogoproto types can be
placed here since standard Protobufs are not registered in the gogoproto
type registry. We lock the `gogo/googleapis` package to 1.2.0 to
use gogoproto 1.2-compatible Protobufs required by CRDB, these have been
verified to not be vulnerable to the "skippy pb" bug.

Note that to preserve error details, gogo-based `Status` objects with
gogo-based details must be used, otherwise details may not be preserved.
This is for similar reasons as outlined above, and is a limitation in
the gRPC package -- see code comments for further details. A CRDB linter
rule forbidding use of `Status.WithDetails()` was submitted in
cockroachdb/cockroach#61617.
erikgrinaker added a commit to erikgrinaker/errors that referenced this pull request Mar 14, 2021
This patch adds support for automatic en/decoding of gRPC `Status`
errors, enabled by importing the `extgrpc` package. It supports statuses
generated both by the standard `google.golang.org/grpc/status` and the
gogoproto-based `github.com/gogo/status` packages.

Encoded statuses are always represented as `gogo/status`-based `Status`
Protobufs, since the `EncodedError` type is a gogoproto type using an
`Any` field for structured errors, and only gogoproto types can be
placed here since standard Protobufs are not registered in the gogoproto
type registry. We lock the `gogo/googleapis` package to 1.2.0 to
use gogoproto 1.2-compatible Protobufs required by CRDB, these have been
verified to not be vulnerable to the "skippy pb" bug.

Note that to preserve error details, gogo-based `Status` objects with
gogo-based details must be used, otherwise details may not be preserved.
This is for similar reasons as outlined above, and is a limitation in
the gRPC package -- see code comments for further details. A CRDB linter
rule forbidding use of `Status.WithDetails()` was submitted in
cockroachdb/cockroach#61617.
erikgrinaker added a commit to erikgrinaker/errors that referenced this pull request Mar 15, 2021
This patch adds support for automatic en/decoding of gRPC `Status`
errors, enabled by importing the `extgrpc` package. It supports statuses
generated both by the standard `google.golang.org/grpc/status` and the
gogoproto-based `github.com/gogo/status` packages.

Encoded statuses are always represented as `gogo/status`-based `Status`
Protobufs, since the `EncodedError` type is a gogoproto type using an
`Any` field for structured errors, and only gogoproto types can be
placed here since standard Protobufs are not registered in the gogoproto
type registry. We lock the `gogo/googleapis` package to 1.2.0 to
use gogoproto 1.2-compatible Protobufs required by CRDB, these have been
verified to not be vulnerable to the "skippy pb" bug.

Note that to preserve error details, gogo-based `Status` objects with
gogo-based details must be used, otherwise details may not be preserved.
This is for similar reasons as outlined above, and is a limitation in
the gRPC package -- see code comments for further details. A CRDB linter
rule forbidding use of `Status.WithDetails()` was submitted in
cockroachdb/cockroach#61617.
erikgrinaker added a commit to erikgrinaker/errors that referenced this pull request Mar 15, 2021
This patch adds support for automatic en/decoding of gRPC `Status`
errors, enabled by importing the `extgrpc` package. It supports statuses
generated both by the standard `google.golang.org/grpc/status` and the
gogoproto-based `github.com/gogo/status` packages.

Encoded statuses are always represented as `gogo/status`-based `Status`
Protobufs, since the `EncodedError` type is a gogoproto type using an
`Any` field for structured errors, and only gogoproto types can be
placed here since standard Protobufs are not registered in the gogoproto
type registry. We lock the `gogo/googleapis` package to 1.2.0 to
use gogoproto 1.2-compatible Protobufs required by CRDB, these have been
verified to not be vulnerable to the "skippy pb" bug.

Note that to preserve error details, gogo-based `Status` objects with
gogo-based details must be used, otherwise details may not be preserved.
This is for similar reasons as outlined above, and is a limitation in
the gRPC package -- see code comments for further details. A CRDB linter
rule forbidding use of `Status.WithDetails()` was submitted in
cockroachdb/cockroach#61617.
erikgrinaker added a commit to cockroachdb/errors that referenced this pull request Mar 17, 2021
This patch adds support for automatic en/decoding of gRPC `Status`
errors, enabled by importing the `extgrpc` package. It supports statuses
generated both by the standard `google.golang.org/grpc/status` and the
gogoproto-based `github.com/gogo/status` packages.

Encoded statuses are always represented as `gogo/status`-based `Status`
Protobufs, since the `EncodedError` type is a gogoproto type using an
`Any` field for structured errors, and only gogoproto types can be
placed here since standard Protobufs are not registered in the gogoproto
type registry. We lock the `gogo/googleapis` package to 1.2.0 to
use gogoproto 1.2-compatible Protobufs required by CRDB, these have been
verified to not be vulnerable to the "skippy pb" bug.

Note that to preserve error details, gogo-based `Status` objects with
gogo-based details must be used, otherwise details may not be preserved.
This is for similar reasons as outlined above, and is a limitation in
the gRPC package -- see code comments for further details. A CRDB linter
rule forbidding use of `Status.WithDetails()` was submitted in
cockroachdb/cockroach#61617.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants