Skip to content

Translate waiters on the Smithy path - #7512

Merged
Fred1155 merged 4 commits into
feature/master/smithy-migrationfrom
bole/smithy_waiters
Nov 11, 2026
Merged

Fred1155 merged 4 commits into
feature/master/smithy-migrationfrom
bole/smithy_waiters

Conversation

@Fred1155

@Fred1155 Fred1155 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Motivations

In the Smithy path, the intermediate model had no waiters, so a client generated from Smithy had no waiter classes or waiter() method. This PR translates Smithy's @waitable trait, following the same approach as the paginator PR #7463.

@waitable can't express three things waiters-2.json has:

  • Attempt limit: every C2J waiter has maxAttempts; Smithy waiters have none.
  • HTTP status matcher: C2J can match on a response status code; Smithy can't.
  • C2J-only waiters: some waiters in waiters-2.json have no @waitable counterpart.

For these, a new codegen trait, software.amazon.awssdk.codegen#waiterOverrides, sits on the operation, keyed by waiter name. Each entry is one of:

  • maxAttempts alone: translate the @waitable waiter with this limit.
  • maxAttempts, delay and acceptors: use this waiters-2.json waiter instead.
  • skip: true: generate no waiter.

Like paginatorOverride, it is applied through smithy-build.json, so model.json is not edited.

Modifications

  1. waiterOverrides trait: defined in aws-sdk-java-codegen-traits.smithy, with the class WaiterOverridesTrait registered as a TraitService. An invalid entry fails when the trait is loaded.
  2. AddSmithyWaiters: builds the waiter map, keyed by waiter name.
    • A skip entry drops the waiter; a full entry is used as written; otherwise the @waitable waiter is translated.

    • Delay is minDelay (Smithy's default of 2 when absent). maxAttempts comes from the override. maxDelay, documentation and deprecation are dropped.

    • Matchers map as follows:

      Smithy matcher C2J acceptor
      success: true / success: false error, expected false / true
      errorType error, type copied as written
      output with stringEquals / booleanEquals path
      output with allStringEquals / anyStringEquals pathAll / pathAny
      inputOutput, or an errorType with a shape ID Fails: the Java waiter runtime can't evaluate it
    • Generation fails, with a message naming the waiter, when a waiter has no maxAttempts or a maxAttempts-only entry has no @waitable waiter.

  3. SmithyIntermediateModelBuilder: passes the waiter map into the intermediate model.
  4. codegen/pom.xml: smithy-waiters moves from runtime to compile scope, because AddSmithyWaiters uses its classes.

Waiters are ordered by name, so some clients list waiter methods in a different order than on C2J. Behavior is the same.

Not in this PR:

  • Writing the overrides: generating waiterOverrides entries from waiters-2.json into smithy-build.json belongs with the smithy-build.json generator, together with paginatorOverride.

Testing

mvn -o test -pl :codegen,:codegen-maven-plugin passed.

New and updated tests:

  • AddSmithyWaitersTest: each matcher's translation, the default minDelay, a full override replacing a @waitable waiter, a full override without one, skip, and each failure case.
  • SmithyCodegenTraitsTest: the trait loads through TraitService, invalid entries are rejected with their messages, and the trait is rejected on a non-operation shape.
  • AwsSdkJavaCodegenPluginTest: a @waitable waiter and an overridden waiter generate waiter classes through smithy-build, and a @waitable waiter without maxAttempts fails.
  • SmithyBuildGeneratorTest (codegen-maven-plugin): the real-model test model now carries a waiterOverrides entry for its waiter, because a @waitable waiter without one fails by design.

Manual one-time check: an all-services intermediate model parity run, with the overrides written from each service's waiters-2.json, found no waiter differences between the Smithy and C2J paths for any compared client.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

The Smithy builder passed an empty waiter map, so no waiters were
generated from a Smithy model.

AddSmithyWaiters translates each @Waitable waiter into the
WaiterDefinition the C2J loader produces: delay from minDelay, and each
acceptor mapped to the C2J matcher that generates the same Java.
errorType is copied as written, as C2J matches the wire error code.
Smithy waiters have no attempt limit, so a new codegen trait,
waiterOverrides, gives maxAttempts for every waiter and fails the build
when it is missing. An entry with delay and acceptors replaces the
@Waitable waiter, for waiters it cannot express (HTTP status matchers),
and skip drops it.

smithy-waiters moves to compile scope. On the plugin classpath without
it, model assembly drops @Waitable with only a warning.
@Fred1155
Fred1155 requested a review from a team as a code owner November 4, 2026 19:26
import software.amazon.smithy.model.shapes.ServiceShape;
import software.amazon.smithy.model.shapes.ShapeId;

class AddSmithyWaitersTest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have tests covering duplicate waiter names across operations, unsupported/unknown smithy matchers and verification of their exception messages?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The unsupported matchers have tests that check their messages. We have no tests for duplicate-name and unknown matcher, since Smithy rejects it during model validation.

… into bole/smithy_waiters

# Conflicts:
#	codegen/src/main/java/software/amazon/awssdk/codegen/smithy/SmithyIntermediateModelBuilder.java
@Fred1155
Fred1155 merged commit 328f7de into feature/master/smithy-migration Nov 11, 2026
5 of 6 checks passed
@github-actions

Copy link
Copy Markdown

This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 11, 2026
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.

2 participants