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

enha: send original error response in ProxyGetRequest #1516

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

dcfreire
Copy link
Contributor

@dcfreire dcfreire commented Jan 9, 2025

closes #1515

@dcfreire dcfreire requested a review from a team as a code owner January 9, 2025 18:27
@dcfreire
Copy link
Contributor Author

dcfreire commented Jan 9, 2025

I tried using an enum instead of deserializing in two places, but it did not work, serde kept failing with "data did not match any variant of untagged enum". I think it has something to do with untagged enums expecting all parameters of the json object to be in the variant's struct, while structs will deserialize even if the json contains extra fields.

@niklasad1
Copy link
Member

I tried using an enum instead of deserializing in two places, but it did not work, serde kept failing with "data did not match any variant of untagged enum". I think it has something to do with untagged enums expecting all parameters of the json object to be in the variant's struct, while structs will deserialize even if the json contains extra fields.

Yes, we are using serde_json::value::RawValue which doesn't work with untagged enums serde-rs/json#779

types/src/error.rs Outdated Show resolved Hide resolved
@niklasad1
Copy link
Member

niklasad1 commented Jan 10, 2025

If you merge master then the UI tests should pass I fixed it right now, new stable rust version broke it

#[derive(serde::Deserialize, serde::Serialize, Debug)]
struct ErrorResponse<'a> {
#[serde(borrow)]
error: &'a serde_json::value::RawValue,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
error: &'a serde_json::value::RawValue,
error: ErrorObject<'a>,

Copy link
Contributor Author

@dcfreire dcfreire Jan 10, 2025

Choose a reason for hiding this comment

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

I applied this by mistake, if it is ok here to directly deserialize to the error object, why not also directly deserialize the result in the success response?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also I think in this case we can just do serde_json::from_slice::<ErrorObject>(&bytes) and not have the ErrorResponse struct at all

Copy link
Contributor Author

@dcfreire dcfreire Jan 10, 2025

Choose a reason for hiding this comment

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

Also I think in this case we can just do serde_json::from_slice::<ErrorObject>(&bytes)

This is incorrect, my bad

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.

Errors to requests that go through ProxyGetRequest are always internal error
3 participants