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

status: fix/improve status handling #6662

Merged
merged 4 commits into from
Oct 2, 2023
Merged

status: fix/improve status handling #6662

merged 4 commits into from
Oct 2, 2023

Commits on Sep 29, 2023

  1. status: fix/improve status handling

    API-layer:
    
    1. If the user sets a status code outside the bounds defined in the `codes`
       package 0-16 (inclusive), set the status code to `codes.Unknown`.  This
       impacts statuses created locally as well as statuses received in RPC
       response trailers.  See grpc/grpc-java#10568 for
       evidence this may be happening in the wild.
    
    Client-side:
    
    1. When receiving a `grpc-status-details-bin` trailer:
    
       - If there is 1 value and it deserializes into a `google.rpc.Status`, ensure
         the code field matches the `grpc-status` header's code.  If it does not
         match, convert the code to `codes.Internal` and set a message indicating
         the mismatch.  If it does, the status will contain the full details of the
         `grpc-status-details-bin` proto.  (Note that `grpc-message` will not be
         checked against the proto's message field, and will be silently discarded
         if there is a mismatch.)
    
       - Otherwise, the status returned to the application will use the
         `grpc-status` and `grpc-message` values only.
    
       - In all cases, the raw `grpc-status-details-bin` trailer will be visible to
         the application via
         `metadata.FromIncomingContext(ctx)["grpc-status-details-bin"]`.
    
    Server-side:
    
    1. If the user manually sets `grpc-status-details-bin` in the trailers:
    
       - If the status returned by the method handler _does not_ include details
         (see `status.(*Status).WithDetails`), the transport will send the user's
         `grpc-status-details-bin` trailer(s) directly.
    
       - If the status returned by the method handler _does_ include details, the
         transport will disregard the user's trailer(s) and replace them with a
         `google.rpc.Status` proto version of the returned status.
    dfawley committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    a16a83c View commit details
    Browse the repository at this point in the history
  2. review comments

    dfawley committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    1804795 View commit details
    Browse the repository at this point in the history
  3. review comments

    dfawley committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    f3cad42 View commit details
    Browse the repository at this point in the history
  4. oops

    dfawley committed Sep 29, 2023
    Configuration menu
    Copy the full SHA
    ac60aab View commit details
    Browse the repository at this point in the history