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

feat: add fallback logic in error handling #1309

Merged
merged 5 commits into from
Aug 17, 2022
Merged

feat: add fallback logic in error handling #1309

merged 5 commits into from
Aug 17, 2022

Conversation

sckimynwa
Copy link
Contributor

@sckimynwa sckimynwa commented Aug 9, 2022

Summary

According to Google API Design Docs (http_mapping), it says below.

While proto3 messages have native JSON encoding, Google's API Platform uses a different error schema for Google's JSON HTTP APIs for backward compatibility reasons.

in order to support AIP Error Format with backward compatibility, i add a fallback logic in parsing errors.

Description

  • when error in normal format(as-is backward-compatibility format). it works like before.
  • but when error in aip format (without 'error' wrapping), all the fields are wrapped in 'error' properties

for example.

Before

{
  "code": 3,
  "grpc-code": "INVALID_ARGUMENT",
  "message": "required field",
  "details": [
    {
      "@type": "type.googleapis.com/google.rpc.BadRequest",
      "fieldViolations": [
        {
          "field": "container_id",
          "description": "required field"
        }
      ]
    }
  ]
}

After

{
  "error": {
    "code": 3,
    "grpc-code": "INVALID_ARGUMENT",
    "message": "required field",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "container_id",
            "description": "required field"
          }
        ]
      }
    ]
  }
}

all test codes work as fine, and if you say ok to these changes, i will add test codes!!

Reference

Fixes below.

Notes

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

@sckimynwa sckimynwa requested a review from a team as a code owner August 9, 2022 09:50
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Aug 9, 2022
@alexander-fenster alexander-fenster self-assigned this Aug 11, 2022
@alexander-fenster alexander-fenster added the kokoro:run Add this label to force Kokoro to re-run the tests. label Aug 14, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Aug 17, 2022
@alexander-fenster alexander-fenster added the kokoro:run Add this label to force Kokoro to re-run the tests. label Aug 17, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Aug 17, 2022
@alexander-fenster alexander-fenster added the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 17, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Aug 17, 2022
@alexander-fenster
Copy link
Contributor

Thank you!

@alexander-fenster alexander-fenster merged commit 6b12234 into googleapis:main Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants