Initializer storageUri is silently overridden by user-provided STORAGE_URI env var
What happened?
When a user sets both initializer.dataset.storageUri (or initializer.model.storageUri)
and a STORAGE_URI entry in initializer.dataset.env / initializer.model.env, the
user-provided env var silently wins, even though storageUri is the structured,
documented field for specifying the source.
In pkg/runtime/framework/plugins/jobset/builder.go, the initializer container's
env vars are built in this order:
if storageUri != nil {
apply.UpsertEnvVars(env, STORAGE_URI=<storageUri>)
}
apply.UpsertEnvVars(env, userEnv...)
Since UpsertEnvVars replaces any existing entry with the same name, if userEnv
also contains STORAGE_URI, it overwrites the value derived from storageUri —
with no error, warning, or indication to the user.
Example:
initializer:
dataset:
storageUri: "hf://tatsu-lab/alpaca"
env:
- name: STORAGE_URI
value: "hf://other/repo"
The TrainJob spec appears to declare hf://tatsu-lab/alpaca as the dataset source,
but the initializer container actually receives hf://other/repo.
What did you expect to happen?
Either:
storageUrishould take precedence as the structured source of truth, and a conflictingSTORAGE_URIinenvshould be rejected/warned at admission time, or- If
envoverridingstorageUriis intentional (e.g. as an escape hatch), this precedence should be explicitly documented, so the TrainJob spec doesn't visually misrepresent what's actually being downloaded.
Currently neither is the case — the override happens silently, and I couldn't find existing docs, KEPs, or tests that establish this as intended behavior.
Environment
- Kubeflow Trainer version: (fill in)
- Relevant file:
pkg/runtime/framework/plugins/jobset/builder.go
Impacted by this bug?
Give it a 👍 We prioritize the issues with most 👍
Opened # to address this.
Thanks @mimosapudical!
Similar to #3956 I'm not sure why a user would set the env variable. If they do they will only break their TrainJob. Is there a scenario you can see where someone may accidentally set this env variable?
My concern is the maintenance cost of the extra validation is unlikely to offset the user benefit. I'm inclined to keep the current behaviour. Wdyt?
Hey @robert-bell , one realistic scenario: people often copy env blocks from existing manifests (old Kubernetes Jobs, Helm charts, other teams' YAML, or examples from before Kubeflow had a storageUri field) that already set STORAGE_URI as a plain env var. When they then fill in the new storageUri field too (because that's the documented way now), they have no reason to expect the two overlap — env looks like a place for extra vars, not something that can silently override a structured field.
So it's less "a careless user broke their own config" and more "the API doesn't signal that this one specific env key has special, overriding power." Even just emitting a warning/event when both are set (without rejecting it) would fix the "no indication to the user" problem you're worried about, without adding real validation/maintenance cost