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

Incorrect RequestRejection yielded when @httpPayload targets string shape #3750

Open
david-perez opened this issue Jul 9, 2024 · 0 comments
Labels
bug Something isn't working server Rust server SDK

Comments

@david-perez
Copy link
Contributor

And the incoming value is not valid UTF-8. Indeed, consider:

@http(uri: "/http-payload-on-string", method: "POST")
operation HttpPayloadOnStringOperation {
    input: HttpPayloadOnString
}

structure HttpPayloadOnString {
    @httpPayload
    message: String
}

We generate:

pub(crate) fn de_message_payload(
    body: &[u8],
) -> std::result::Result<
    ::std::option::Option<::std::string::String>,
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
> {
    (!body.is_empty())
        .then(|| {
            let body_str = std::str::from_utf8(body)?;
            Ok(body_str.to_string())
        })
        .transpose()
}

What RequestRejection do we yield? We're leveraging this #[from] conversion when using ? above:

#[error("request URI cannot be percent decoded into valid UTF-8")]
PercentEncodedUriNotValidUtf8(#[from] core::str::Utf8Error),

Thus returning an incorrect rejection. We're not percent-decoding a URI here!

@david-perez david-perez added bug Something isn't working server Rust server SDK labels Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server Rust server SDK
Projects
None yet
Development

No branches or pull requests

1 participant