Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: restjson error deserialization when no body is present #4817

Merged
merged 1 commit into from
May 8, 2023

Conversation

lucix-aws
Copy link
Contributor

@lucix-aws lucix-aws commented Apr 27, 2023

Closes #4811.

  • allow restjson error deserialization (unmodeled or otherwise) without a response body
  • check auxiliary __type field for error code
  • update error code sanitization to remove both namespace and details
  • much more comprehensive test suite

// a modeled error will have to be re-deserialized later, so the body must
// be preserved
var buf bytes.Buffer
tee := io.TeeReader(resp.Body, &buf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the PR description, it states: allow restjson error deserialization (unmodeled or otherwise) without a response body

but it looks like here if we fail to deserialize the error on headers alone, we still fallback to the response body? so how are we allowing error deserialization without a response body?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the change is to not explode when there's no body. We have and still do fall back to inspecting the body if the headers don't give us the information we need.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

restJson error deserialization fails on empty body
3 participants