Skip to content

fix: handle explicit null member defaults for enums and intEnums#752

Merged
jonathan343 merged 2 commits into
developfrom
null-handling-testing
Jul 24, 2026
Merged

fix: handle explicit null member defaults for enums and intEnums#752
jonathan343 merged 2 commits into
developfrom
null-handling-testing

Conversation

@jonathan343

Copy link
Copy Markdown
Contributor

Summary

Fixes a Python codegen crash when a structure member overrides an enum or intEnum default with an explicit @default(null).

Problem

A member can set @default(null) to mark itself nullable even when its target enum declares a non-null default. This is valid Smithy that appears in real AWS models (e.g. bedrock-agentcore-control's UpdatePolicyRequest$enforcementMode). In existing codegen, StructureGenerator.getDefaultValue sent these into the enum/intEnum branches, which read the default as a string/number without a null check and threw:

ExpectationNotMetException: Expected string, but found null.

Solution

Guard for a null default at the top of getDefaultValue so every non-document type resolves to None before the typed branches run (documents are excluded, their null default is a non-None Document(None)).

Added defaultNull{Enum,IntEnum,Blob,Timestamp} members to the integration model to cover this path.


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

@jonathan343
jonathan343 requested a review from a team as a code owner July 24, 2026 05:03

@arandito arandito left a comment

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.

:shipit:

@jonathan343
jonathan343 merged commit 4b98778 into develop Jul 24, 2026
10 checks passed
@jonathan343
jonathan343 deleted the null-handling-testing branch July 24, 2026 18:50
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