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 serialized result of LifecycleRuleAndOperator #2476

Closed
JaySon-Huang opened this issue May 5, 2023 · 4 comments
Closed

Incorrect serialized result of LifecycleRuleAndOperator #2476

JaySon-Huang opened this issue May 5, 2023 · 4 comments
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@JaySon-Huang
Copy link

JaySon-Huang commented May 5, 2023

Describe the bug

Creating a lifecycle rule with LifecycleRuleAndOperator is failed

Expected Behavior

The rule is created

Current Behavior

The PutBucketLifecycleConfiguration request is rejected with error message like this

[2023/05/05 14:45:22.645 +08:00] [TRACE] [S3Common.cpp:144] ["tag=AWSClient message=Request returned error. Attempting to generate appropriate error codes from response"] [source=AWSClient] [thread_id=1]
[2023/05/05 14:45:22.645 +08:00] [WARN] [S3Common.cpp:144] ["tag=AWSErrorMarshaller message=Encountered Unknown AWSError 'InvalidRequest': The XML you provided was not well-formed or did not validate against our published schema"] [source=AWSClient] [thread_id=1]
[2023/05/05 14:45:22.645 +08:00] [ERROR] [S3Common.cpp:144] ["tag=AWSXmlClient message=HTTP response code: 400\nResolved remote host IP address: 172.16.5.85:9000\nRequest ID: 175C2C594517BF2B\nException name: InvalidRequest\nError message: Unable to parse ExceptionName: InvalidRequest Message: The XML you provided was not well-formed or did not validate against our published schema\n12 response headers:\naccept-ranges : bytes\nconnection : close\ncontent-length : 346\ncontent-security-policy : block-all-mixed-content\ncontent-type : application/xml\ndate : Fri, 05 May 2023 06:45:22 GMT\nserver : MinIO\nstrict-transport-security : max-age=31536000; includeSubDomains\nvary : Accept-Encoding\nx-amz-request-id : 175C2C594517BF2B\nx-content-type-options : nosniff\nx-xss-protection : 1; mode=block"] [source=AWSClient] [thread_id=1]

Reproduction Steps

    std::vector<Aws::S3::Model::Tag> filter_tags{
        Aws::S3::Model::Tag().WithKey("k").WithValue("v"),
    };

    Aws::S3::Model::LifecycleRule rule;
    rule.WithStatus(Aws::S3::Model::ExpirationStatus::Enabled)
        .WithFilter(Aws::S3::Model::LifecycleRuleFilter()
                        .WithAnd(Aws::S3::Model::LifecycleRuleAndOperator()
                                     .WithPrefix("")
                                     .WithTags(filter_tags)))
        .WithExpiration(Aws::S3::Model::LifecycleExpiration()
                            .WithDays(expire_days))
        .WithID("gc");

    Aws::Vector<Aws::S3::Model::LifecycleRule> rules{rule};
    Aws::S3::Model::BucketLifecycleConfiguration lifecycle_config;
    lifecycle_config
        .WithRules(rules);

    Aws::S3::Model::PutBucketLifecycleConfigurationRequest request;
    request.WithBucket(client.bucket())
        .WithLifecycleConfiguration(lifecycle_config);

    auto outcome = client.PutBucketLifecycleConfiguration(request);

Possible Solution

I tried to create the same rule by using awscli, it was successful. Then I use tcpdump to compare the PUT body of using aws-sdk-cpp and awscli.

PUT body of aws-sdk-cpp

<?xml version="1.0"?>
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Rule>
        <Expiration>
            <Days>1</Days>
        </Expiration>
        <ID>gc</ID>
        <Filter>
            <And>
                <Prefix></Prefix>
                <Tags>
                    <Tag>
                        <Key>k</Key>
                        <Value>v</Value>
                    </Tag>
                </Tags>
            </And>
        </Filter>
        <Status>Enabled</Status>
    </Rule>
</LifecycleConfiguration>

PUT body of awscli

<LifecycleConfiguration>
    <Rule>
        <ID>ch5nt3fpvdtf2nk2eap0</ID>
        <Status>Enabled</Status>
        <Filter>
            <And>
                <Prefix/>
                <Tag>
                    <Key>k</Key>
                    <Value>v</Value>
                </Tag>
            </And>
        </Filter>
        <Expiration>
            <Days>1</Days>
        </Expiration>
    </Rule>
</LifecycleConfiguration>

It is clear that there is an extra <Tags> layer make the request failed


There is a simple fix for removing the <Tags></Tags> from LifecycleRuleAndOperator
JaySon-Huang/aws-sdk-cpp@75b6642...2e64cb4#diff-741ea2316c42c441bb04008c57b2fe74778b8cb5538b603b8e911ddfd31fcca3

But I see the file LifecycleRuleAndOperator.cpp was added by a commit with comment "Regenerating Clients". I wonder whether something is wrong with the code generator or the definition.

Additional Information/Context

No response

AWS CPP SDK version used

https://github.com/aws/aws-sdk-cpp/releases/tag/1.11.48

Compiler and Version used

clang version 15.0.1

Operating System and version

all

@sbiscigl
Copy link
Contributor

sbiscigl commented May 8, 2023

Hey thanks for opening the issue

I wonder whether something is wrong with the code generator or the definition.

Something was wrong with code generation where we were not correctly generating serialization for list shapes that were flattened without flat list members. Created a PR to fix this, running CI tests on it right now, will give a shout when it gets merged.

@sbiscigl
Copy link
Contributor

sbiscigl commented May 8, 2023

fix is merged, and will be release and tagged today in 1.11.75, closing, give a shout if you have any more questions.

@sbiscigl sbiscigl closed this as completed May 8, 2023
@github-actions
Copy link

github-actions bot commented May 8, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@JaySon-Huang
Copy link
Author

Great to see this is fixed in the coming patch version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants