smithy-lang / smithy

Smithy is a protocol-agnostic interface definition language and set of tools for generating clients, servers, and documentation for any programming language.
https://smithy.io
Apache License 2.0
1.7k stars 201 forks source link

Revert EC2 Query Protocol empty list serialization #2269

Closed syall closed 2 months ago

syall commented 2 months ago

Overview

Revert EC2 Query Protocol empty list serialization.

Empty lists are NOT serialized for the EC2 query protocol, which differs from the AWS query protocol. See "EmptyQueryLists" for the AWS query protocol equivalent test case.

This is needed since SDKs that conform to the broken protocol tests will send invalid requests to EC2.

Testing

Tested with aws-sdk-js-v3 locally (smithy-typescript, aws-sdk-js-v3) sending a previously failing command with the error InvalidRequest: The request received was invalid. now with the correct validation error.

const { EC2Client: Client, DescribeKeyPairsCommand: Command } = require("@aws-sdk/client-ec2");

(async () => {
    const client = new Client();
    client.middlewareStack.add(next => async (args) => {
        console.info(args.request.body);
        return await next(args);
    }, { step: 'finalizeRequest' });
    try {
        await client.send(new Command({
            Filters: [],
            KeyPairIds: ["key-KEYISNOTREALATALL"],
        }));
    } catch (error) {
        console.error(error);
    }
})();

Before:

Filter=&KeyPairId.1=key-KEYISNOTREALATALL&Action=DescribeKeyPairs&Version=2016-11-15
InvalidRequest: The request received was invalid.

After:

KeyPairId.1=key-KEYISNOTREALATALL&Action=DescribeKeyPairs&Version=2016-11-15
InvalidParameterValue: Invalid value 'key-KEYISNOTREALATALL' for keyPairId.

The Filter= empty list serialization is removed.

- Filter=&KeyPairId.1=key-KEYISNOTREALATALL&Action=DescribeKeyPairs&Version=2016-11-15
+ KeyPairId.1=key-KEYISNOTREALATALL&Action=DescribeKeyPairs&Version=2016-11-15

Links


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.