GoogleContainerTools/skaffold · error
invalid env variable format: %s, should be KEY=VALUE
Error message
invalid env variable format: %s, should be KEY=VALUE
What it means
Profile auto-activation can be driven by environment variables via `profiles.activation.env`. `isEnv` (pkg/skaffold/schema/profiles.go:209) parses each env value and requires the literal form KEY=VALUE. If the configured value contains no `=` at all, SplitN yields one element and the activation evaluation cannot proceed, so it returns this error.
Source
Thrown at pkg/skaffold/schema/profiles.go:209
if err != nil {
return false, err
}
kubeContext, err := isKubeContext(cond.KubeContext, opts)
if err != nil {
return false, err
}
return command && env && kubeContext, nil
}
func isEnv(env string) (bool, error) {
if env == "" {
return true, nil
}
keyValue := strings.SplitN(env, "=", 2)
if len(keyValue) != 2 {
return false, fmt.Errorf("invalid env variable format: %s, should be KEY=VALUE", env)
}
key := keyValue[0]
value := keyValue[1]
envValue := os.Getenv(key)
// Special case, since otherwise the regex substring check (`re.Compile("").MatchString(envValue)`)
// would always match which is most probably not what the user wanted.
if value == "" {
return envValue == "", nil
}
return skutil.RegexEqual(value, envValue), nil
}
func isCommand(command string, opts cfg.SkaffoldOptions) bool {
if command == "" {View on GitHub (pinned to a1189de023)
Solutions
- Change the activation entry to include a value: `env: CI=true` (or the desired value, e.g. `env: ENV=staging`)
- If you only care whether the variable is set (to any value), use `env: CI=` style per skaffold docs semantics or list each KEY=VALUE pair explicitly
- Validate skaffold.yaml with `skaffold diagnose` to catch malformed activation blocks before running
Example fix
# before
profiles:
- name: prod
activation:
- env: PROD
# after
profiles:
- name: prod
activation:
- env: PROD=true Defensive patterns
Strategy: validation
Validate before calling
yq '.profiles[].activation[]?.env // empty' skaffold.yaml | grep -v '=' && echo 'must be KEY=VALUE'
Prevention
- Write activation env entries as KEY=VALUE
- Lint skaffold.yaml with skaffold diagnose in CI
When it happens
Trigger: skaffold.yaml contains a profile activation `env:` entry that is a bare name like `env: CI` or `env: DEBUG_MODE` instead of `env: CI=true`. It is evaluated whenever profile auto-activation runs (activatedProfiles -> isProfileActivated -> isActivationTriggered -> isEnv) during ApplyProfiles.
Common situations: Hand-written skaffold.yaml where the author expected a bare variable name to mean 'env var is set'; copying Kubernetes-style env entries; YAML quoting mistakes that drop the `=VALUE` part; typos like `env: FOO BAR`.
Related errors
- invalid path: %s
- value must be one of `always`, `missing`, or `never`
- CONFIG_REMOTE_REPO_CACHE_NOT_FOUND_ERR
- CONFIG_REMOTE_REPO_CACHE_NOT_FOUND_ERR
- INSPECT_BUILD_ENV_ALREADY_EXISTS_ERR
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/e8ff072980c0146e.
Report an issue: GitHub.