#7403·kubevela

[Bug] vela/velaconfig reader: Secret identity, output namespaces and fallback keys

Author: briankaneCreated Sep 28, 2026Updated Sep 28, 2026
Labelstype/bugarea/cueeffort/smallarea/provider

Is there an existing issue for this?

  • I have searched the existing issues

Affected area

CUE providers (vela/velaconfig), Config CRD (config.oam.dev/v1alpha1)

KubeVela version

master only. The reader arrived with SourceDefinition (#7371) and the Config CRD with #7211; neither is in a release yet, so this can be fixed before one ships.

Repos: kubevela only. The reader uses pkg/config's factory and reads what the Config controller (pkg/controller/config.oam.dev/v1alpha1/config) stores. #7400 moves the reader, unchanged, from cmd/core/app/bootstrap.go to pkg/cue/cuex/providers/velaconfig/reader, so the line numbers below are for that file.

Describe the bug

Review of #7400 turned up five things in how the reader reads a Config. None is a regression from that PR; they came in with the code it moved.

  1. Any labelled Secret reads as a Config. ReadConfig reads the named Secret's input-properties, and GetConfig accepts any Secret with non-nil labels (convertSecret2Config, pkg/config/factory.go:1075). Nothing checks config.oam.dev/catalog: velacore-config, so a source can read a Secret that is not a Config, if it has labels and an input-properties key. (reader.go:55)
  2. Output namespaces disagree between the two render paths. The Config controller's renderOutputs forces every output into the Config's namespace (config_controller.go:291), but pkg/config's ParseConfig keeps whatever namespace the template declares. The reader re-renders with ParseConfig and matches by apiVersion|kind|namespace|name, so for a template that declares a namespace, the match misses and the output falls back to a Kind/name key instead of its template label. (reader.go:94-98)
  3. The fallback key can collide. When the re-render fails, outputs are keyed Kind/name, so two outputs of the same kind and name in different namespaces or API versions collapse into one map entry. (reader.go:100)
  4. The Secret is read twice, and a comment is stale. ReadConfig then GetConfig each read the Secret. The comment says GetConfig only blanks a sensitive Config, but it returns ErrSensitiveConfig too (pkg/config/factory.go:706), so one GetConfig would do. (reader.go:55)
  5. The fallback weakens the velaconfig.#Read contract. #Read says outputs are keyed by template label; the fallback silently keys them by Kind/name. It is documented as intentional ("A failure here is not fatal"), but a consumer cannot tell which keying it got. Worth deciding whether to surface it (an error, or a field saying the labels are unknown). (reader.go:100)

To reproduce

For 2: create a ConfigTemplate whose outputs entry sets metadata.namespace to something other than the Config's namespace, create a Config from it through the CRD, then read it with velaconfig.#Read. The output comes back under Kind/name, not its label.

For 1: create any Secret with a label and an input-properties key holding JSON, then velaconfig.#Read it by name.

Expected behavior

  1. Only a Secret carrying the Config catalog label is read as a Config.
  2. Both render paths agree on output namespaces (normalise before keying, or make ParseConfig match the controller).
  3. The fallback key includes namespace and API version.
  4. One read, with the comment corrected.
  5. A decision on whether the fallback is visible to the consumer.

Additional context

Raised by cubic on #7400, #7401 and #7402: