Skip to content

Incorrect RequestRejection yielded when @httpPayload targets string shape #3750

Open
@david-perez

Description

@david-perez

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingserverRust server SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions