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

Fill the errors attribute for HTTP errors #1528

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

manuteleco
Copy link
Contributor

Some GCS client libraries (like this one), are quite strict when it comes to the set of attributes they expect to find in the error response. If any of those attributes is missing, they fail to deserialize the error.

In fake-gcs-server, the httpError.Errors attribute was always initialized to nil, causing the error.errors JSON response attribute to be omitted and leading to failures in some client libraries.

In this commit we address that issue by always providing content on the errors attribute (httpError.Errors field) whenever we return an error response. The implementation is kept simple without aiming to return exactly the same values that are officially documented. The main goal is to have a sensible response that is structurally correct for the purposes of deserialization client-side.

Some GCS client libraries (like [this one][1]), are quite strict when it
comes to the set of attributes they expect to find in the error
response. If any of those attributes is missing, they fail to
deserialize the error.

In `fake-gcs-server`, the `httpError.Errors` attribute was always
initialized to `nil`, causing the `error.errors` JSON response attribute
to be omitted and leading to failures in some client libraries.

In this commit we address that issue by always providing content on the
`errors` attribute (`httpError.Errors` field) whenever we return an
error response. The implementation is kept simple without aiming to
return exactly the same values that are [officially documented][2]. The
main goal is to have a sensible response that is _structurally_ correct
for the purposes of deserialization client-side.

[1]: https://crates.io/crates/google-cloud-storage
[2]: https://cloud.google.com/storage/docs/json_api/v1/status-codes
Copy link
Owner

@fsouza fsouza left a comment

Choose a reason for hiding this comment

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

Thank you for contributing!

@fsouza fsouza merged commit 7c79b19 into fsouza:main Mar 13, 2024
27 checks passed
@manuteleco manuteleco deleted the fill_errors_list_in_response branch March 14, 2024 19:23
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.

2 participants