Skip to content

PR 4721: Schema-based client uses modeled Accept header after switching protocols #4802

Description

@drganjoo

Description

A client generated with RpcV2Cbor as its modeled protocol can select RestJson1 at runtime through the config bag. The resulting RestJson1 request incorrectly uses the modeled RpcV2Cbor Accept header:

accept: application/cbor

The multi-protocol Pokemon server rejects the request with HTTP 405.

Reproduction

The complete reproducer is on the upstream branch
fahadzub/4721-accept-error.

Fetch the branch and generate the Pokemon client and server:

git fetch origin fahadzub/4721-accept-error
git switch --detach origin/fahadzub/4721-accept-error
make -C examples

Start the server:

cd examples
cargo run --bin pokemon-service

In another terminal, run the client reproducer:

cd examples
cargo run --quiet \
    -p pokemon-service-client-usage \
    --example accept-header-repro

The example selects RestJson1 at runtime:

let config = Config::builder()
    .endpoint_url(POKEMON_SERVICE_URL)
    .protocol(
        aws_smithy_json::protocol::aws_rest_json_1::AwsRestJsonProtocol::new()
            .with_default_namespace("com.aws.example"),
    )
    .build();

Actual behavior

expected Accept="application/json"
actual Accept=Some("application/cbor")
result=Err(ServiceError(... StatusCode(405) ...))

Expected behavior

The runtime-selected RestJson1 protocol should send:

accept: application/json

The request should complete successfully.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions