envFrom validation errors have no entry index, and their paths are garbled when several entries are invalid

オープン 初心者向け
#16,790 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@BahaaMattar がすでに取り組んでいます。

2026年11月19日 から。

  • #16791 @BahaaMattar による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
77/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go, kubernetes
領域
api, backend, testing

調査の方向性

pkg/apis/serving/k8s_validation.go の validateEnvFrom から始め、各 envFrom エントリに対してどのようにエラーを追加するかを追ってください。無効な最初のエントリの後に有効なエントリが続くケースを使った Service.Validate の単体テストで問題を再現してください。各エラーパスに正しいエントリインデックスが含まれ、後続のエントリの影響を受けない状態になれば完了です。

索引モデルが issue の本文から書いたものです。

説明

area/API kind/bug

/kind bug
/area API

What version of Knative?

main (8045f4b)

Actual Behavior

For a container with several envFrom entries where an earlier one has neither configMapRef nor secretRef, the validation error is:

expected exactly one, got neither: spec.template.spec.containers[0].envFrom.configMapRef[2].secretRef[1].configMapRef, spec.template.spec.containers[0].envFrom.configMapRef[2].secretRef[1].secretRef

The wrong entry is entry 0, but no index is shown, and the path was rewritten by the entries that follow it. With a single bad entry the path has no index at all (...envFrom.configMapRef, ...envFrom.secretRef).

Expected Behavior

expected exactly one, got neither: spec.template.spec.containers[0].envFrom[0].configMapRef, spec.template.spec.containers[0].envFrom[0].secretRef

Steps to Reproduce the Problem

  1. Validate a Service whose container has envFrom: [{prefix: A_}, {secretRef: {name: s}}, {configMapRef: {name: c}}] (first entry has no ref), e.g. Service.Validate in a unit test.
  2. Read the error above.

Cause: in validateEnvFrom (pkg/apis/serving/k8s_validation.go), .ViaIndex(i).ViaField("secretRef") / .ViaField("configMapRef") is chained onto errs.Also(...), i.e. onto all errors collected so far, and the "one of" errors never get ViaIndex(i).

主要言語
Go
スター
6.1k
フォーク
1.2k
平均マージ
1日 15時間
マージ済み PR(30日)
51

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

knative/serving のほかの issue

knative/serving の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。