fix(python): synthesize defaults for required fields missing from examples in wire tests#13454
Merged
iamnamananand996 merged 1 commit intomainfrom Mar 12, 2026
Conversation
…mples in wire tests
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
🌱 Seed Test SelectorSelect languages to run seed tests for:
How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR. |
amckinney
approved these changes
Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refs: getbrevo/brevo-python#25, getbrevo/brevo-python#27
Fixes a bug where generated wire tests instantiate required types without populating required fields, causing Pydantic
ValidationErrorat runtime. For example,BatchDeleteObjectRecordsRequestIdentifiersIds()is generated with no args even thoughids: List[int]is required.Link to Devin Session: https://app.devin.ai/sessions/0ef5ad19238e478d973dee98f739e425
Requested by: @iamnamananand996
Changes Made
DynamicTypeLiteralMapper.convertObjectEntries()to detect required properties missing from the example and synthesize reasonable default valuessynthesizeDefaultValue()dispatcher that handles all type categories (primitives, literals, lists, sets, maps, named types, unknown)synthesizeDefaultPrimitive()with sensible defaults per primitive ("string"for strings,1for ints,1.1for floats, etc.)synthesizeDefaultLiteral()andsynthesizeDefaultNamed()(handles aliases, enums, objects) with recursion prevention via aseenset to avoid infinite loops on circular type referencesUserProfileVerification()→UserProfileVerification(verified="string"))4.63.6changelog entryImportant Review Points
nop():discriminatedUnionandundiscriminatedUniondon't get synthesized defaults — if a required field is a union type, it will still be omitted. Is this acceptable or should we pick the first variant?python.TypeInstantiation.str(firstValue.wireValue)) rather than an enum class reference — verify this is correct for generated test codeassociateByWireValuepattern exists inEndpointSnippetGeneratorfor top-level body args, but those are less likely to hit this issue since IR examples typically include top-level required fieldsTesting