cli-plugins/hooks: max-message enforcement is off by one
まだ誰も着手していません。
評価
調査の方向性
cli-plugins/hooks/template.go の 43 行目と 46 行目から始め、issue にある 11 行の再現コードを使って hooks.ParseTemplate() を調査します。10 個の改行文字が拒否される一方で、10 メッセージの上限以内の出力は有効なままであることを示す回帰テストを追加します。完了の条件は、余分な行が最終メッセージに結合されないことです。
索引モデルが issue の本文から書いたものです。
説明
Description
cli-plugins/hooks.ParseTemplate() currently enforces maxMessages = 10 by counting newline characters and rejecting only when strings.Count(out, "\n") > maxMessages, then returning strings.SplitN(out, "\n", maxMessages).
That makes the limit off by one:
- a template that renders to 10 newline characters actually contains 11 messages
- that output is currently accepted instead of rejected
SplitN(..., 10)then merges the extra line into the last returned element, so the final "message" can still contain an embedded newline
This means the "maximum 10 messages" guard can be bypassed by one extra rendered line.
Reproduce
- Use the current
masterbranch. - Call
hooks.ParseTemplate()with output that contains 11 lines, for example:
strings.Repeat("line\n", 10) + "line"
- Observe that no error is returned.
- Observe that the returned slice has length 10, with the last element containing an embedded newline.
The relevant logic is currently in:
cli-plugins/hooks/template.go:43cli-plugins/hooks/template.go:46
Expected behavior
A template that renders to more than 10 messages should be rejected, including the 11-line / 10-newline case.
In other words, the limit should be enforced on the number of returned messages, not just on the number of newline separators.
docker version
N/A for runtime environment. This is a source-level issue in the current master branch checkout.
Observed in local checkout at 9f16882de4.
docker info
N/A for runtime environment. This issue is in template parsing logic and does not depend on daemon configuration.
Additional Info
This looks like it was introduced by b7ab63387a (cli-plugins/hooks: limit maximum number of lines / messages).
I’m happy to send a fix with a regression test if this behavior matches the intended bug report.
- 主要言語
- Go
- スター
- 6.1k
- フォーク
- 2.2k
- 平均マージ
- 1日 15時間
- マージ済み PR(30日)
- 43
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
docker/cli のほかの issue
-
kind/bug status/0-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
kind/feature status/0-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
kind/bug status/0-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
kind/bug status/0-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
-
area/ux kind/enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
-
enhancement needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
kind/cleanup
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
kubernetes-sigs/kueue#15947 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sympozium-ai/sympozium#627 ·