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

aws: Fix Pagination handling of empty string NextToken #94

Merged
merged 2 commits into from
Jan 15, 2018

Conversation

jasdel
Copy link
Contributor

@jasdel jasdel commented Jan 15, 2018

Fixes the SDK's handling of a Pagination NextToken's value being an
empty string compared to a nil value. The SDK was expecting NextToken's
to always be unset (nil) and treating any non-nil value as a valid
value. This was not the case in MediaLive's List APIs. As those APIs
return a empty string value instead of null or not setting the field at
all.

This issue exists in both the v1 and v2 SDKs.

Fix #84

Fixes the SDK's handling of a Pagination NextToken's value being an
empty string compared to a nil value. The SDK was expecting NextToken's
to always be unset (nil) and treating any non-nil value as a valid
value. This was not the case in MediaLive's List APIs. As those APIs
return a empty string value instead of null or not setting the field at
all.

This issue exists in both the v1 and v2 SDKs.

Fix aws#84
@jasdel jasdel self-assigned this Jan 15, 2018
@jasdel jasdel requested a review from xibz January 15, 2018 19:34
@jasdel jasdel mentioned this pull request Jan 15, 2018
}{
{aws.String("FirstValue"), aws.String("InitalToken"), aws.String("FirstToken")},
{aws.String("SecondValue"), aws.String("FirstToken"), aws.String("SecondToken")},
{aws.String("ThirdValue"), aws.String("SecondToken"), nil},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not have a test to test for ""?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, TestPagination_Standalone is that testcase. The SDK already had this testcase but the way it worked prevented the bug from manifesting.

}

tokenAdded = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if they are bunch of empy strings, wouldn't tokenAdded not be set to true? Meaning this would never return the tokens

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tokenAdded is present if a valid token is added. The tokens slice is a sparse array. Its index directly correspond to indexes in another slice.

If all of the values at the outTokens paths are empty strings there will be no valid tokens in the tokens slice. In that case returning nil would be the correct action. If there is at least one valid value in outTokens paths the tokenAdded will be set to true.

@jasdel jasdel merged commit ed4e5c9 into aws:master Jan 15, 2018
@jasdel jasdel mentioned this pull request Jan 15, 2018
jasdel added a commit that referenced this pull request Jan 15, 2018
Release v2.0.0-preview.2 (2018-01-15)
===

### Services
* Synced the V2 SDK with latests AWS service API definitions.

### SDK Bugs
* `service/s3/s3manager`: Fix Upload Manger's UploadInput fields ([#89](#89))
	* Fixes [#88](#88)
* `aws`: Fix Pagination handling of empty string NextToken ([#94](#94))
	* Fixes [#84](#84)
jasdel added a commit to jasdel/aws-sdk-go that referenced this pull request Jan 15, 2018
Fixes the SDK's handling of a Pagination NextToken's value being an
empty string compared to a nil value. The SDK was expecting NextToken's
to always be unset (nil) and treating any non-nil value as a valid
value. This was not the case in MediaLive's List APIs. As those APIs
return a empty string value instead of null or not setting the field at
all.

V1 SDK port of aws/aws-sdk-go-v2#94
jasdel added a commit to aws/aws-sdk-go that referenced this pull request Jan 26, 2018
Fixes the SDK's handling of a Pagination NextToken's value being an
empty string compared to a nil value. The SDK was expecting NextToken's
to always be unset (nil) and treating any non-nil value as a valid
value. This was not the case in MediaLive's List APIs. As those APIs
return a empty string value instead of null or not setting the field at
all.

V1 SDK port of aws/aws-sdk-go-v2#94
xibz pushed a commit to xibz/aws-sdk-go that referenced this pull request Feb 15, 2018
)

Fixes the SDK's handling of a Pagination NextToken's value being an
empty string compared to a nil value. The SDK was expecting NextToken's
to always be unset (nil) and treating any non-nil value as a valid
value. This was not the case in MediaLive's List APIs. As those APIs
return a empty string value instead of null or not setting the field at
all.

V1 SDK port of aws/aws-sdk-go-v2#94
@jasdel jasdel deleted the bug/EmptyStringNextToken branch March 6, 2018 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants