fix(go): dedupe union base properties that collide with extended properties#16276
fix(go): dedupe union base properties that collide with extended properties#16276iamnamananand996 wants to merge 2 commits into
Conversation
…erties A discriminated union that both extends an object and declares base-properties with an overlapping name (e.g. property-access fixture: extends Foo and base-property normal, both yielding a Normal field) emitted duplicate struct fields, getters, and marshaler entries, so the generated Go did not compile. Skip base properties whose exported name is already contributed by an extended object.
🤖 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:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
…edFailures conflict
Description
Second in the one-by-one series to clear
seed/go-sdk/seed.ymlallowedFailures. Fixes theproperty-accessfixture.A discriminated union that both
extendsan object and declaresbase-propertieswith an overlapping name produced duplicate Go fields. In the fixture,UserOrAdminDiscriminateddoes:Both the extended
Foo.normaland the base-propertynormalmapped to aNormalfield, so the v1 model generator emittedNormaltwice →types.go:488: Normal redeclared, duplicateGetNormal, and duplicate struct-literal keys. The generated SDK did not compile.Changes Made
generators/go/internal/generator/model.go: addedunionExtendedPropertyNames()helper that collects (transitively) the exported field names contributed by a union'sextends. InVisitUnion(struct def,UnmarshalJSON,MarshalJSON) andgetTypeFieldsForUnion(getters), base properties whose exported name is already contributed by an extended object are skipped — the extended property already covers them.seed/go-sdk/seed.yml: removedproperty-accessfromallowedFailures.seed/go-sdk/property-access/(types.go,types_test.go): singleNormalfield/getter now.generators/go/sdk/changes/unreleased/fix-union-base-property-collision.yml(type: fix).Testing
pnpm seed test --generator go-sdk --fixture property-access --localnow passes (was abuildfailure:Normal redeclared).go-sdkseed suite: onlyproperty-accessoutput changed; no other fixture's generated code changed (verified viagit status). Remaining failures are the still-listedallowedFailuresplus known flaky WireMock runtime tests that generate byte-identical code tomain.go build ./...,go vet,go test ./internal/generator/..., andgofmtall clean.Link to Devin session: https://app.devin.ai/sessions/6ba63e4405694aa8ab8875f0dbfd9afc
Requested by: @iamnamananand996