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 paginator bug where None was returned immediately #1083

Merged
merged 4 commits into from
Jan 18, 2022
Merged

Conversation

rcoh
Copy link
Collaborator

@rcoh rcoh commented Jan 18, 2022

Motivation and Context

Description

The escape hatch added by aws-sdk-rust#391 did not properly handle the case where the first response was None and not the empty string. This diff:

  • Checks for emptiness for both maps and strings
  • Fixes the check so that an initial None input does not cause an incorrect paginator error

Testing

  • added to canary
  • added mocked-traffic IT

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

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

@rcoh rcoh requested a review from a team as a code owner January 18, 2022 16:21
rcoh added 2 commits January 18, 2022 11:25
The escape hatch added by aws-sdk-rust#391 did not properly handle the case where the first response was `None` and _not_ the empty string. This diff:
- Checks for emptiness for both maps and strings
- Fixes the check so that an initial `None` input does not cause an incorrect paginator error
@rcoh rcoh force-pushed the paginators-bug-redux branch from fd52ddc to 0344ae9 Compare January 18, 2022 16:26
@github-actions
Copy link

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

@github-actions
Copy link

A new doc preview is ready to view.


/// See https://github.com/awslabs/aws-sdk-rust/issues/405
///
/// EC2 can also reply with the token truly unset which will be interpreted as `None`
Copy link
Contributor

Choose a reason for hiding this comment

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

What exactly does this mean? How many "kinds" of unset are there? I can think of
a. field returned but empty or set to a value signifying empty
b. no field returned

Were we only covering case a previously and now we're covering case b too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah it can either be <nextToken></nextToken>, or as is the case here, <nextToken> is not present in the response at all. In one case, we get Some(""), in the other, we get None. None used to be handled properly, but regressed when I added the failsafe to avoid infinite loops

} else {
return "$token.is_none()"
}
return "$token.map(|token|token.is_empty()).unwrap_or(true)"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should prefer function pointers in place of closures where possible:

Suggested change
return "$token.map(|token|token.is_empty()).unwrap_or(true)"
return "$token.map(String::is_empty).unwrap_or(true)"

It might not be possible depending on how type inference interprets this though

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this can be either a string or a hashmap

tools/ci-cdk/canary-lambda/src/paginator_canary.rs Outdated Show resolved Hide resolved
rcoh and others added 2 commits January 18, 2022 11:45
@github-actions
Copy link

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

@github-actions
Copy link

A new doc preview is ready to view.

@rcoh rcoh merged commit 21ffa90 into main Jan 18, 2022
@rcoh rcoh deleted the paginators-bug-redux branch January 18, 2022 17:46
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.

2 participants