go: closed discriminated union UnmarshalJSON panics on JSON null
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
調査の方向性
Start at templates/templates/go/union.go.stmpl: compare the dis == nil guard emitted for open unions around line 225 with the closed-union discriminator switch. Reproduce with a closed union used as a required field whose JSON value is null, then make the closed path reset the union and return a descriptive error instead of dereferencing dis. Done means the template change plus regenerated review fixtures for Go, CLI and the Terraform provider all show the new behavior.
索引モデルが issue の本文から書いたものです。
説明
Summary
The Go union template (templates/templates/go/union.go.stmpl) unmarshals the discriminator with json.Unmarshal(data, &dis) where dis is a pointer. When the input is JSON null, dis is set to nil and switch dis.<Field> dereferences it. The dis == nil guard is only emitted for open unions (line 225), so every closed discriminated union generated for Go, CLI, and Terraform can nil-deref.
Repro
Any closed discriminated union used as a required (non-pointer) field, with the server returning null for that field. For pointer fields encoding/json short-circuits to nil without calling UnmarshalJSON, so the required-field case is the one that reaches the switch.
Expected
Closed unions should treat null like an unknown discriminator: reset the union and return a descriptive error rather than panicking.
Scope
Shared template, so the fix lands in Go, CLI, and the Terraform provider SDK at once and regenerates the review fixtures for each.
- 主要言語
- Go
- スター
- 37
- フォーク
- 12
- 平均マージ
- 2日 1時間
- マージ済み PR(30日)
- 67
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
nebari-dev/llm-serving-pack#270 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
area/controller
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
volcano-sh/kthena#2109 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
unbound-force/replicator#193 ·
メンテナーはふだん 2 日以内に返信