Dispatcher panics when a failed delivery returns a response body larger than 768 bytes
メンテナーはふだん 1 日以内に返信
@RaphaelFakhri がすでに取り組んでいます。
2026年11月3日 から。
評価
調査の方向性
パニックは pkg/kncloudevents/event_dispatcher.go の593行目付近にある dispatchExecutionInfoTransformers から発生しています。このバッファは KnativeErrorDataExtensionMaxLength で上限が設定されていますが、レスポンスボディ全体がそこにエンコードされています。まずこの関数と、TestSendEvent の invalid destination with a large response body and delivery option のケースを読み、そのテストを実行して index-out-of-range パニックを再現してください。768バイトを超えるボディでテストが通り、knativeerrordata の値がボディを1024文字に切り詰めたものの base64 になっていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
When a subscriber or trigger destination returns a non-2xx response with a body longer than 768 bytes, and the delivery has a dead letter sink (or a reply), the dispatcher panics with runtime error: index out of range in encoding/base64.(*Encoding).Encode.
dispatchExecutionInfoTransformers in pkg/kncloudevents/event_dispatcher.go caps the destination buffer at KnativeErrorDataExtensionMaxLength (1024) but encodes the whole response body into it:
encodedLen := base64.StdEncoding.EncodedLen(bodyLen)
if encodedLen > attributes.KnativeErrorDataExtensionMaxLength {
encodedLen = attributes.KnativeErrorDataExtensionMaxLength
}
encodedBuf := make([]byte, encodedLen)
base64.StdEncoding.Encode(encodedBuf, httpResponseBody)
base64.Encode always writes EncodedLen(len(src)) bytes, so it panics if the buffer is shorter than that.
Effects:
- In the in-memory channel dispatcher, the fanout runs each subscription in its own goroutine, so the panic is not recovered and the dispatcher process exits.
- In the broker filter,
net/httprecovers the panic, the connection is dropped, and the event never reaches the dead letter sink.
Expected behavior
The event goes to the dead letter sink, and knativeerrordata holds the base64-encoded response body truncated to 1024 characters.
To Reproduce
- Create a Trigger or Subscription with
delivery.deadLetterSinkset. - Point the subscriber at a service that returns HTTP 500 with a body of 2000 bytes (for example, an HTML error page).
- Send an event. The dispatcher logs
panic: runtime error: index out of rangeand the dead letter sink receives nothing.
The unit test case invalid destination with a large response body and delivery option in TestSendEvent reproduces this on main:
panic: runtime error: index out of range [3] with length 0
encoding/base64.(*Encoding).Encode(...)
knative.dev/eventing/pkg/kncloudevents.dispatchExecutionInfoTransformers(...)
pkg/kncloudevents/event_dispatcher.go:593
Knative release version
main (2153953). The same code has been in place since at least the kncloudevents refactor (#7092).
Additional context
Bodies of 768 bytes or fewer are not affected, because their encoded length fits in the buffer.
- 主要言語
- Go
- スター
- 1.6k
- フォーク
- 637
- 平均マージ
- 10時間 57分
- マージ済み PR(30日)
- 13
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
knative/eventing のほかの issue
-
auto:flaky
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
knative/eventing#9597 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
auto:flaky
難易度 4/5 1〜2日 初心者へのやさしさ 32/100
knative/eventing#9596 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[flaky] test/rekt.TestInMemoryChannelTLS/SubscriptionTLSTrustBundle/Requirement/channel_is_readyオープンauto:flaky
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
knative/eventing#9595 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
auto:flaky
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
knative/eventing#9594 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
auto:flaky
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
knative/eventing#9593 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
knative/eventing の issue をすべて見る
似ている issue
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
orion-belt-dev/orion-belt#181 ·
メンテナーはふだん 1 日以内に返信
-
documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
kubesmarts/logic-operator#105 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
jakartaee/jakartablogs.ee#125 ·
-
story
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
patch-it-dev/patch-it-plugins#120 ·
メンテナーはふだん 1 日以内に返信
-
[Plugin] calendarオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
MUKE-coder/grit#228 ·