fix: deserialize enum values in Go union factories - #8234
Shubham Padkonde (Shubham-Padkonde) wants to merge 10 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues remain, and regression coverage addresses the reported cases.
Review effort: Lite
Findings: None
What changed in this PR
Fixes Go union factory generation for scalar enum deserialization and undiscriminated unions.
Changes:
- Adds guarded enum type assertions.
- Skips empty discriminator lookups.
- Adds regression coverage and changelog documentation.
| File | Summary |
|---|---|
tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs |
Adds enum and discriminator regression tests. |
src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs |
Corrects union factory generation. |
CHANGELOG.md |
Documents the fixes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Shubham Padkonde (@Shubham-Padkonde) your behaviour is disruptive, opening about 30 PRs on the repos in a couple of hours time, most likely code that was AI generated and not tested/reviewed, will only clog our review pipeline. Please stop opening additional pull requests and work on the comments added to existing ones. We have turned on pull requests limits on this repository, and will proceed to blocking you at the organization level if additional pull requests are opened on other repositories before the already opened ones are reviewed and closed/or merged. |
|
Shubham Padkonde (@Shubham-Padkonde) this PR is conflicting, would you mind handling the conflicts when you have a minute please? |
|
Shubham Padkonde (@Shubham-Padkonde) this PR is not linked to an issue, can you edit the initial PR description and add |
|
This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged. |
|
Conflicts have been resolved. A maintainer will take a look shortly. |
|
This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged. |
|
Conflicts have been resolved. A maintainer will take a look shortly. |
|
This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged. |
|
Conflicts have been resolved. A maintainer will take a look shortly. |
|
This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged. |
|
Conflicts have been resolved. A maintainer will take a look shortly. |
Fixes #7808.
Addresses #7808.
Go union factories pass the
interface{}returned byGetEnumValuedirectly to a typed enum setter. Use the same guarded enum type assertion as intersection factories. Collection handling and primitive assignments remain unchanged.The same undiscriminated factory also reads
GetChildNode(""); the JSON parse node rejects that before either enum or integer parsing can run. Read discriminator values only when discriminator information is present.Validation:
interface{}passed to*Status). An external cast-only reproduction then fails enum and integer JSON parsing withindex is empty.go test -race ./...andgo vet ./...on Go 1.26.3, including both JSON runtime cases using kiota-serialization-json-go 1.1.2.Changed C# files pass scoped formatting verification.