{"record":{"id":"7de84ad24d033288","repo":"GoogleContainerTools/skaffold","slug":"couldn-t-parse-image-tag-w","errorCode":null,"errorMessage":"couldn't parse image tag: %w","messagePattern":"couldn't parse image tag: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/docker/image.go","lineNumber":342,"sourceCode":"}\n\nfunc (l *localDaemon) CheckCompatible(a *latest.DockerArtifact) error {\n\tif len(a.Secrets) > 0 || a.SSH != \"\" {\n\t\treturn fmt.Errorf(\"docker build options, secrets and ssh, require BuildKit - set `useBuildkit: true` in your config, or run with `DOCKER_BUILDKIT=1`\")\n\t}\n\treturn nil\n}\n\n// Build performs a docker build and returns the imageID.\nfunc (l *localDaemon) Build(ctx context.Context, out io.Writer, workspace string, artifact string, a *latest.DockerArtifact, opts BuildOptions) (string, error) {\n\tlog.Entry(ctx).Debugf(\"Running docker build: context: %s, dockerfile: %s\", workspace, a.DockerfilePath)\n\n\tif err := l.CheckCompatible(a); err != nil {\n\t\treturn \"\", err\n\t}\n\timageInfoEnv, err := EnvTags(opts.Tag)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"couldn't parse image tag: %w\", err)\n\t}\n\tbuildArgs, err := EvalBuildArgsWithEnv(opts.Mode, workspace, a.DockerfilePath, a.BuildArgs, opts.ExtraBuildArgs, imageInfoEnv)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to evaluate build args: %w\", err)\n\t}\n\n\t// Like `docker build`, we ignore the errors\n\t// See https://github.com/docker/cli/blob/75c1bb1f33d7cedbaf48404597d5bf9818199480/cli/command/image/build.go#L364\n\tauthConfigs, _ := DefaultAuthHelper.GetAllAuthConfigs(ctx)\n\n\tbuildCtx, buildCtxWriter := io.Pipe()\n\tgo func() {\n\t\terr := CreateDockerTarContext(ctx, buildCtxWriter,\n\t\t\tNewBuildConfig(workspace, artifact, a.DockerfilePath, buildArgs), l.cfg)\n\t\tif err != nil {\n\t\t\tbuildCtxWriter.CloseWithError(fmt.Errorf(\"creating docker context: %w\", err))\n\t\t\treturn\n\t\t}","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/docker/image.go#L324-L360","documentation":"The image tag string produced by opts.Tag could not be parsed by EnvTags, which extracts environment-variable-style tag references. Build aborts early before any Docker API call so a malformed tag never reaches the daemon. The underlying parse error is wrapped for context.","triggerScenarios":"Calling localDaemon.Build with BuildOptions.Tag containing a string EnvTags cannot parse (e.g. invalid characters, missing/malformed tag portion, unexpected format produced by a custom tagger or templating misconfiguration in skaffold.yaml).","commonSituations":"A custom tagger template (e.g. {{.TAG}} placeholders) renders an empty or invalid tag; a date/git tagger emits characters invalid for image names; a user passes a hand-written tag with spaces or uppercase in the wrong place via tooling.","solutions":["Inspect the tag value passed in BuildOptions.Tag and fix its format (valid `name:tag` reference)","Check the tagger configuration in skaffold.yaml (template, envTemplate) for typos or unset environment variables","Run skaffold with debug logging to see the exact tag string being generated"],"exampleFix":"// before (custom tagger producing invalid tag)\ntagPolicy:\n  envTemplate:\n    template: \"{{.BREAKING_ENV}}\"\n// after\ntagPolicy:\n  envTemplate:\n    template: \"{{.IMAGE_NAME}}:{{.VERSION}}\"","handlingStrategy":"validation","validationCode":"if tag == \"\" || strings.ContainsAny(tag, \" \\t\") {\n\treturn fmt.Errorf(\"invalid image tag: %q\", tag)\n}\nif _, err := docker.EnvTags(tag); err != nil {\n\treturn fmt.Errorf(\"invalid tag before build: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"imageID, err := daemon.Build(ctx, out, ws, artifact, a, opts)\nif err != nil && strings.Contains(err.Error(), \"couldn't parse image tag\") {\n\treturn fmt.Errorf(\"fix BuildOptions.Tag (%q): %w\", opts.Tag, err)\n}","preventionTips":["Validate tagger output (templates, env vars) before builds","Test custom tag templates locally with sample data","Avoid hand-crafting tag strings; use the built-in taggers"],"tags":["docker","image-tag","parsing"],"backgroundTag":"invalid-image-tag","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"}