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: update test operation generator to find any operation in the service closure #3922

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

mcmasn-amzn
Copy link
Contributor

Motivation and Context

When using operations nested under resources, the current search will raise "NoSuchElementException". This fixes the search to include all operations within the service closure

Description

The error is visible in client generates like this:

Projection rust-client failed: java.util.NoSuchElementException: Collection contains no element matching the predicate.
java.util.NoSuchElementException: Collection contains no element matching the predicate.
        at software.amazon.smithy.rustsdk.endpoints.OperationInputTestGeneratorKt.operationId(OperationInputTestGenerator.kt:242)
        at software.amazon.smithy.rustsdk.endpoints.OperationInputTestGenerator$operationInvocation$1.invoke(OperationInputTestGenerator.kt:183)
        at software.amazon.smithy.rustsdk.endpoints.OperationInputTestGenerator$operationInvocation$1.invoke(OperationInputTestGenerator.kt:180)

Testing

gradle :aws:sdk-codegen:check

Checklist

  • For changes to the smithy-rs codegen or runtime crates, I have created a changelog entry Markdown file in the .changelog directory, specifying "client," "server," or both in the applies_to key.
  • For changes to the AWS SDK, generated SDK code, or SDK runtime crates, I have created a changelog entry Markdown file in the .changelog directory, specifying "aws-sdk-rust" in the applies_to key.

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

…vice closure

When using operations nested under resources, the current search will raise "NoSuchElementException".
This fixes the search to include all operations within the service closure
@mcmasn-amzn mcmasn-amzn marked this pull request as ready for review November 26, 2024 21:09
@mcmasn-amzn mcmasn-amzn requested a review from a team as a code owner November 26, 2024 21:09
Copy link

github-actions bot commented Dec 2, 2024

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@landonxjames
Copy link
Contributor

Copy link
Contributor

@landonxjames landonxjames left a comment

Choose a reason for hiding this comment

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

Having to use a Smithy index like this instead of just iterating through all the operations is a bit of a smithy footgun and I think there are probably several other places in the codebase that do this. Thanks for catching it and providing the test!

@mcmasn-amzn
Copy link
Contributor Author

Thanks @landonxjames. Yes, I wrote the original code here in 2023 and didn't realize serviceShape.allOperations doesn't recurse through attached resources. It's a surprising behavior, but also, one that's probably tricky to fix without breaking existing callers.

@landonxjames
Copy link
Contributor

Canary passed and the semver test failure is currently expected, merging

@landonxjames landonxjames added this pull request to the merge queue Dec 9, 2024
Merged via the queue into smithy-lang:main with commit f1f9e8f Dec 9, 2024
40 of 42 checks passed
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