Skip to content

fix(python): synthesize defaults for required fields missing from examples in wire tests#13454

Merged
iamnamananand996 merged 1 commit intomainfrom
devin/1773330605-fix-wire-test-required-fields
Mar 12, 2026
Merged

fix(python): synthesize defaults for required fields missing from examples in wire tests#13454
iamnamananand996 merged 1 commit intomainfrom
devin/1773330605-fix-wire-test-required-fields

Conversation

@iamnamananand996
Copy link
Contributor

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 ValidationError at runtime. For example, BatchDeleteObjectRecordsRequestIdentifiersIds() is generated with no args even though ids: List[int] is required.

Link to Devin Session: https://app.devin.ai/sessions/0ef5ad19238e478d973dee98f739e425
Requested by: @iamnamananand996

Changes Made

  • Modified DynamicTypeLiteralMapper.convertObjectEntries() to detect required properties missing from the example and synthesize reasonable default values
  • Added synthesizeDefaultValue() dispatcher that handles all type categories (primitives, literals, lists, sets, maps, named types, unknown)
  • Added synthesizeDefaultPrimitive() with sensible defaults per primitive ("string" for strings, 1 for ints, 1.1 for floats, etc.)
  • Added synthesizeDefaultLiteral() and synthesizeDefaultNamed() (handles aliases, enums, objects) with recursion prevention via a seen set to avoid infinite loops on circular type references
  • Updated dynamic snippet snapshots reflecting the fix (e.g. UserProfileVerification()UserProfileVerification(verified="string"))
  • Added version 4.63.6 changelog entry

Important Review Points

  1. Union types return nop(): discriminatedUnion and undiscriminatedUnion don'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?
  2. Enum defaults use raw wire value string (python.TypeInstantiation.str(firstValue.wireValue)) rather than an enum class reference — verify this is correct for generated test code
  3. Only nested objects are fixed: The same associateByWireValue pattern exists in EndpointSnippetGenerator for top-level body args, but those are less likely to hit this issue since IR examples typically include top-level required fields
  4. Seed tests not yet run — should be validated by CI or manually

Testing

  • Dynamic snippet snapshot tests updated and passing (32/32)
  • TypeScript compilation passes
  • Biome lint checks pass
  • Seed tests pending (CI)

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Contributor

🌱 Seed Test Selector

Select languages to run seed tests for:

  • Python
  • TypeScript
  • Java
  • Go
  • Ruby
  • C#
  • PHP
  • Swift
  • Rust
  • OpenAPI
  • Postman

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.

@iamnamananand996 iamnamananand996 merged commit e055df3 into main Mar 12, 2026
191 of 194 checks passed
@iamnamananand996 iamnamananand996 deleted the devin/1773330605-fix-wire-test-required-fields branch March 12, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants