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

What is the server behavior for routing based on query strings when multiple values appear for the same query key parameter? #1070

Open
david-perez opened this issue Jan 31, 2022 · 1 comment
Labels
guidance Question that needs advice or information. protocol-test New protocol tests are needed server This issue involves the specification for server software.

Comments

@david-perez
Copy link
Contributor

The docs don't specify a behavior. Relevant section in the docs: https://awslabs.github.io/smithy/1.0/spec/core/http-traits.html#query-string-literals

There are also no protocol tests.

An example. Consider two routes with URI request patterns:

  1. /path?fooKey=bar
  2. /path?fooKey=baz

And we receive an HTTP request with URI http://yourhost/path?fooKey=bar&fooKey=baz. Where should we route it to?

Note that currently this scenario is accepted by Smithy i.e. this minimal model builds fine:

$version: "1.0"

namespace com.amazonaws.simple

use aws.protocols#restJson1

@restJson1
@title("SimpleService")
service SimpleService {
    version: "2022-01-01",
    operations: [
        Healthcheck1,
        Healthcheck2,
    ],
}

@http(uri: "/healthcheck?fooKey=bar", method: "GET")
operation Healthcheck1 {
    input: HealthcheckInputRequest,
    output: HealthcheckOutputResponse
}

@http(uri: "/healthcheck?fooKey=baz", method: "GET")
operation Healthcheck2 {
    input: HealthcheckInputRequest,
    output: HealthcheckOutputResponse
}

structure HealthcheckInputRequest {
}

structure HealthcheckOutputResponse {
}
@JordonPhillips
Copy link
Contributor

If the operation can't be determined, you throw a serialization exception. It's pretty clear that this would be indeterminable, though I suppose your question could also be phrased as "How should duplicate query keys be treated?". The answer to that can be found here:

List and set members are serialized by adding multiple query string parameters to the query string using the same name. For example, given a member bound to foo that targets a list of strings with a value of ["a", "b"], the value is serialized in the query string as foo=a&foo=b.

So since we treat duplicate entries as lists, the query params in your example could be represented in JSON as:

{
    "fooKey": ["bar", "baz"]
}

But you're expecting fooKey to have a value of bar or baz. Since it has neither of those values, the intended request cannot be determined and you must then return an error.

@mtdowling mtdowling added the guidance Question that needs advice or information. label Dec 15, 2022
@kstich kstich added the protocol-test New protocol tests are needed label Aug 15, 2023
@kstich kstich added the server This issue involves the specification for server software. label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information. protocol-test New protocol tests are needed server This issue involves the specification for server software.
Projects
None yet
Development

No branches or pull requests

4 participants