Skip to content

Give every shape its own synthetic operation in python-type-codegen - #928

Open
akarshy21 wants to merge 2 commits into
smithy-lang:developfrom
akarshy21:fix/types-synthetic-operation-ids
Open

akarshy21 wants to merge 2 commits into
smithy-lang:developfrom
akarshy21:fix/types-synthetic-operation-ids

Conversation

@akarshy21

@akarshy21 akarshy21 commented Nov 11, 2026 •

Copy link
Copy Markdown

Issue #, if available: Fixes #927, fixes #929

Description of changes:

Two bugs that made python-type-codegen leave classes out of the generated models.py, one commit each.

Unique synthetic operation IDs (#927). CreateSyntheticService.transform wraps each selected shape in a synthetic operation named TypesGenOperation<index>, but increments index only for plain shapes, not for error, @input or @output shapes. Such a shape shares its operation ID with the next shape. When the model is rebuilt, one of the two operations replaces the other, and shapes only it reached are never generated. No error is reported. This change increments index once per synthetic operation.

Honor generateInputsAndOutputs (#929). CreateSyntheticService included @input/@output structures when the setting was on, but DirectedPythonTypeCodegen.shouldGenerateStructure always skipped them in types mode, so the setting had no effect. The plugin now passes the setting to the generator, which writes those structures (classes and schemas) when it is on; the default is unchanged. fromNode also lists selector and generateInputsAndOutputs as known settings, so using them no longer logs an "additional properties" warning.

Testing:

  • New integration tests in PythonTypeCodegenTest, each run with both fixes, with only the first, and with neither:

    Test Both python-type-codegen silently omits classes for shapes that follow an error shape #927 fix only Neither
    testEveryShapeIsGeneratedAlongsideErrors pass pass fail (ErrorA, ErrorB, ErrorD, ErrorE missing)
    testInputsAndOutputsAreSkippedByDefault pass pass fail (errors missing)
    testInputsAndOutputsAreGeneratedWhenEnabled pass fail (all inputs/outputs missing) fail
    testInputsAndOutputsAreGeneratedForServiceWhenEnabled pass fail (all inputs/outputs missing) fail
  • ./gradlew build: the plugins:types checks and integration tests pass. Locally, four core Markdown-conversion tests (testConvertHtmlToMarkdownWithList and three others) fail with or without this change, because my pandoc (3.5) indents list items differently from the version CI installs.

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

CreateSyntheticService incremented the operation index only for shapes that
get a synthetic input wrapper, so an error (or a kept @input/@output shape)
shared its operation ID with the next shape. One of the two operations then
replaced the other, and shapes only it reached were silently left out of
models.py. Increment the index once per operation and test that every error
and structure is generated.
@akarshy21
akarshy21 requested a review from a team as a code owner November 11, 2026 22:24
CreateSyntheticService included @input and @output structures when
generateInputsAndOutputs was set, but DirectedPythonTypeCodegen always
skipped them in types mode, so the setting had no effect. Pass the setting
to the generator and generate those structures when it is on. Also list
selector and generateInputsAndOutputs as known settings so using them no
longer logs an additional-properties warning.
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.

python-type-codegen ignores generateInputsAndOutputs python-type-codegen silently omits classes for shapes that follow an error shape

1 participant