{"record":{"id":"46d5aff39ee0ca49","repo":"GoogleContainerTools/skaffold","slug":"unable-to-evaluate-cli-flags-w","errorCode":null,"errorMessage":"unable to evaluate cli flags: %w","messagePattern":"unable to evaluate cli flags: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/docker/image.go","lineNumber":691,"sourceCode":"\t\tif v == nil {\n\t\t\targs = append(args, k)\n\t\t} else {\n\t\t\targs = append(args, fmt.Sprintf(\"%s=%s\", k, *v))\n\t\t}\n\t}\n\n\tfor _, host := range a.AddHost {\n\t\targs = append(args, \"--add-host\", host)\n\t}\n\n\tfor _, from := range a.CacheFrom {\n\t\targs = append(args, \"--cache-from\", from)\n\t}\n\n\tfor _, cliFlag := range a.CliFlags {\n\t\tcliFlag, err := util.ExpandEnvTemplate(cliFlag, env)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to evaluate cli flags: %w\", err)\n\t\t}\n\t\targs = append(args, cliFlag)\n\t}\n\n\tif a.Target != \"\" {\n\t\targs = append(args, \"--target\", a.Target)\n\t}\n\n\tif a.NetworkMode != \"\" {\n\t\targs = append(args, \"--network\", strings.ToLower(a.NetworkMode))\n\t}\n\n\tif a.NoCache {\n\t\targs = append(args, \"--no-cache\")\n\t}\n\n\tif a.Squash {\n\t\targs = append(args, \"--squash\")","sourceCodeStart":673,"sourceCodeEnd":709,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/docker/image.go#L673-L709","documentation":"When building the `docker build` argument list, each entry of the artifact's CliFlags is expanded with util.ExpandEnvTemplate, substituting environment variables into the user-provided flag string. If a flag references an undefined or malformed template variable, the error is wrapped as \"unable to evaluate cli flags: %w\". This is a configuration error in the skaffold artifact definition, not a Docker problem.","triggerScenarios":"A build artifact's `cliFlags` (dockerfile buildArgs section) contains an env-template like `{{.MY_VAR}}` or `$MY_VAR` where MY_VAR is unset in the environment, or the template syntax itself is invalid.","commonSituations":"CI environment missing a variable that exists locally, typo in the variable name inside cliFlags, leftover `{{` syntax from copy-paste, variable only defined in a shell profile that the skaffold process doesn't inherit.","solutions":["Export the referenced environment variable before running skaffold (`export MY_VAR=...`).","Fix the variable name in the skaffold.yaml cliFlags — check for typos against the actual env.","Remove invalid template syntax from the flag string (stray `{{`/`}}`).","Provide a default in the flag value or set the variable in CI pipeline configuration."],"exampleFix":"// before (skaffold.yaml)\ncliFlags: [\"--build-arg\", \"TOKEN={{.MISSING_TOKEN}}\"]\n// after\ncliFlags: [\"--build-arg\", \"TOKEN={{.TOKEN}}\"]\n# with: export TOKEN=abc123","handlingStrategy":"validation","validationCode":"// expand the same templates locally before invoking the build\nfor _, f := range artifact.CliFlags {\n    if _, err := util.ExpandEnvTemplate(f, env); err != nil {\n        return fmt.Errorf(\"cli flag %q needs env vars that are unset: %w\", f, err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document required env vars for cliFlags and set them in CI pipelines.","Grep skaffold.yaml for `{{` templates and cross-check each name with the environment.","Provide defaults for optional variables instead of bare references.","Run skaffold diagnose / a dry parse before long builds."],"tags":["config","docker","env-template","cli-flags"],"backgroundTag":"missing-env-var","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}