Skip to content

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

Open

Description

@BahaaMattar

/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).

Activity

  1. added
    kind/bug
    area/API
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/APIkind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions