Codegen: Name collision for subresource of same name as new top-level resource
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 85
- Forks
- 26
- Avg merge
- 11h 49m
- Merged PRs (30d)
- 22
Description
What happened?
I generated the Java SDK for pulumi-pagerduty against the latest upstream, which has a new top-level data source GetEventOrchestrationIntegration as of upstream v2.13.0.
However, anotherdata source called GetEventOrchestration has had an attribute with nested fields called integration since last year.
When generating the SDK this results in a naming collision and a panic upon assertion.
Expected Behavior
SDK gets generated correctly, as did all other languages.
Steps to reproduce
Attempt to upgrade the PagerDuty provider to upstream latest:
https://github.com/pulumi/upgrade-provider/blob/main/README.md
Manual steps here: https://github.com/pulumi/platform-providers-team/blob/main/playbooks/tf-provider-updating.md
On make build_java, the upgrade fails with following error and trace:
panic: fatal: An assertion has failed: duplicate file: src/main/java/com/pulumi/pagerduty/inputs/GetEventOrchestrationIntegrationArgs.java
goroutine 1 [running]:
github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.failfast(...)
/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.36.1-0.20220725155140-d69eea638451/go/common/util/contract/failfast.go:23
github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.Assertf(0xa0?, {0x1b79a3a?, 0xc0004845a0?}, {0xc0008ee5d0?, 0xe52?, 0x4e?})
/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.36.1-0.20220725155140-d69eea638451/go/common/util/contract/assert.go:33 +0xed
github.com/pulumi/pulumi-java/pkg/codegen/java.fs.add(0xc0008ee678?, {0xc0004845a0, 0x53}, {0xc000b73000, 0xe52, 0x1000})
/home/runner/work/pulumi-java/pulumi-java/pkg/codegen/java/gen.go:1688 +0xd0
github.com/pulumi/pulumi-java/pkg/codegen/java.(*modContext).gen.func1({{0xc00073bb40, 0x3, 0x4}, {0xc000043db5, 0x6}}, {0xc0003e3fb0?, 0x24?}, {0xc000b72000, 0xe52})
/home/runner/work/pulumi-java/pulumi-java/pkg/codegen/java/gen.go:1730 +0x409
github.com/pulumi/pulumi-java/pkg/codegen/java.(*modContext).gen.func2({{0xc00073bb40, 0x3, 0x4}, {0xc000043db5, 0x6}}, {0xc0003e3fb0, 0x24}, 0x400?)
/home/runner/work/pulumi-java/pulumi-java/pkg/codegen/java/gen.go:1738 +0x175
github.com/pulumi/pulumi-java/pkg/codegen/java.(*modContext).gen(0xc00009e900, 0xc00093d0b0)
/home/runner/work/pulumi-java/pulumi-java/pkg/codegen/java/gen.go:1871 +0x1364
github.com/pulumi/pulumi-java/pkg/codegen/java.GeneratePackage({0x1b76ad9?, 0x35?}, 0x0?, 0x0?)
/home/runner/work/pulumi-java/pulumi-java/pkg/codegen/java/gen.go:2094 +0x14f
main.generateJava({{0x7ffeefbff89c, 0x32}, {0xc000036240, 0x35}, {0x7ffeefbff8d5, 0x8}, {0x0, {0x0, 0x0}, {0x1b6c500, ...}, ...}, ...})
/home/runner/work/pulumi-java/pulumi-java/pkg/cmd/pulumi-java-gen/generate.go:80 +0x68c
main.newGenerateCommand.func1(0x0?, {0x8000105?, 0x0?, 0xc00085fd70?})
/home/runner/work/pulumi-java/pulumi-java/pkg/cmd/pulumi-java-gen/command.go:151 +0xa58
github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil.RunFunc.func1(0x6?, {0xc0001a93e0?, 0xc00085fd88?, 0x11c8925?})
/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.36.1-0.20220725155140-d69eea638451/go/common/util/cmdutil/exit.go:96 +0x26
github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil.RunResultFunc.func1(0xc0002b8780?, {0xc0001a93e0, 0x0, 0x6})
/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.36.1-0.20220725155140-d69eea638451/go/common/util/cmdutil/exit.go:112 +0x4f
github.com/spf13/cobra.(*Command).execute(0xc0002b8780, {0xc0001a9320, 0x6, 0x6})
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:860 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0xc0002b8280)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902
main.main()
/home/runner/work/pulumi-java/pulumi-java/pkg/cmd/pulumi-java-gen/main.go:25 +0x25
make: *** [build_java] Error 2
Output of pulumi about
CLI
Version 3.64.0
Go Version go1.20.3
Go Compiler gc
Host
OS darwin
Version 11.7.1
Arch x86_64
Backend
Name pulumi.com
URL https://app.pulumi.com/guinevere-pulumi-corp
User guinevere-pulumi-corp
Organizations guinevere-pulumi-corp, pulumi
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with pkg/codegen/java/gen.go, especially the generation paths shown in the panic, and run the make build_java reproduction against the PagerDuty provider upgrade. Trace why GetEventOrchestrationIntegrationArgs.java is emitted twice when a nested integration field shares a top-level resource name. Done means the Java SDK generates successfully without the duplicate-file assertion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100