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

fix(clients): handle empty xml tags #3623

Merged
merged 3 commits into from Jun 8, 2022
Merged

Conversation

AllanZhengYP
Copy link
Contributor

@AllanZhengYP AllanZhengYP commented May 19, 2022

Issue

Resolves: #3585
Follow up to: #885 #914 #919 #955

Description

The underlying xml parser used by the SDK(fast-xml-parser) parses the self-closing tags(e.g. <Filter/>) to empty string(e.g. { "Filter": "" }). The mentioned PRs(#914 #919 #955) adds early return to the parser. If the parsed value of the member is empty string, it will return default empty value. If the member is a Map, then the empty value is {}; If the member is a Collection(List), then the empty value is [].

However the generated code has 2 issues:

  1. The early if statement was not effective as the later if statement will still attempt to parse the subordinary shape out of "". For example

    if (output.Tag === "") {
      contents.Tags = []; // <== this is overwritten
    }
    if (output["Tag"] !== undefined) { 
      contents.Tags = deserializeAws_restXmlTagSet(__getArrayIfSingleItem(output["Tag"]), context);
    }

    fix:

    if (output.Tag === "") {
      contents.Tags = [];
    }
    else if (output["Tag"] !== undefined) { 
      contents.Tags = deserializeAws_restXmlTagSet(__getArrayIfSingleItem(output["Tag"]), context);
    }
  2. The Union shape as a special type of structure that requires exactly one member, should also be skipped if serialized in empty tag, just like Map and Collection.

This change fixes both issues.

Testing

Unit-test


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@AllanZhengYP AllanZhengYP requested a review from a team as a code owner May 19, 2022 16:06
kuhe
kuhe previously approved these changes May 23, 2022
The underlying xml parser(fast-xml-parser) used in the SDK parses
self-closing tags value as "". For Collections, Map and Union shape
the parser should return early to skip parsing the subordinary
shapes out of "".
@AllanZhengYP AllanZhengYP merged commit 543a0ce into aws:main Jun 8, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError for getBucketLifecycleConfiguration() in aws-sdk/client-s3
2 participants