Value.Patch: "add" with an out-of-range array index appends instead of failing
@SashaMIT がすでに取り組んでいます。
2026年10月12日 から。
評価
調査の方向性
patch.go で patchAdd と find を読んでから始め、レポートにある Go の例で問題を再現してください。利用可能であれば、既存の patch 関連テストを確認してください。add 操作で配列の長さより大きいインデックスを指定した場合にエラーを返して配列を変更せず、長さと等しいインデックスと - トークンの場合は引き続き末尾に追加されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
What happened
An add operation whose array index is greater than the array length succeeds and appends the value.
v, _ := hujson.Parse([]byte(`[1,2]`))
err := v.Patch([]byte(`[{"op":"add","path":"/5","value":3}]`))
fmt.Println(err, string(v.Pack()))
// <nil> [1,2,3]
What you expected
RFC 6902, section 4.1 states that the index of an add on an array must not be greater than the number of elements. The patch should fail with an error and leave the array unchanged. Indexes equal to the length and the - token continue to append.
Cause
patchAdd in patch.go accepts any errNotFound from find as an insertion point. For arrays, find reports the array length as the index for every missing index, so /5 is treated the same as /2 or /-.
- 主要言語
- Go
- スター
- 892
- フォーク
- 40
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tailscale/hujson のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Standardize modifies its input slice; the doc comment does not say so対応中かも @jihtsan が 29 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 60/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
Value.Patch: "test" operation always fails for a null value対応中かも @RaphaelFakhri が 34 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
Patching with comments対応中かも @Shubham-Padkonde が 47 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
tailscale/hujson の issue をすべて見る
似ている issue
-
area: interop area: sip-core v3
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
fonoster/routr#705 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deadfin-org/deadfin#35 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
-
enhancement priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
labmonkeys-space/nl6#1037 ·
メンテナーはふだん 1 日以内に返信
-
Setup Guide Go tab: say it needs Go 1.26 (the unversioned go get pulls OpenTelemetry Go v1.47.0)オープンenhancement follow-up
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信