{"record":{"id":"58c4eba7897f31a8","repo":"goreleaser/goreleaser","slug":"failed-to-process-build-flag-template-s-w","errorCode":null,"errorMessage":"failed to process build flag template '%s': %w","messagePattern":"failed to process build flag template '(.+?)': %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pipe/docker/docker.go","lineNumber":365,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"failed to execute image template '%s': %w\", imageTemplate, err)\n\t\t}\n\t\tif image == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\timages = append(images, image)\n\t}\n\n\treturn images, nil\n}\n\nfunc processBuildFlagTemplates(ctx *context.Context, docker config.Docker) ([]string, error) {\n\t//nolint:prealloc\n\tvar buildFlags []string\n\tfor _, buildFlagTemplate := range docker.BuildFlagTemplates {\n\t\tbuildFlag, err := tmpl.New(ctx).Apply(buildFlagTemplate)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to process build flag template '%s': %w\", buildFlagTemplate, err)\n\t\t}\n\t\tbuildFlags = append(buildFlags, buildFlag)\n\t}\n\treturn buildFlags, nil\n}\n\nfunc dockerPush(ctx *context.Context, image *artifact.Artifact) error {\n\tlog.WithField(\"image\", image.Name).Info(\"pushing\")\n\n\tdocker := artifact.MustExtra[config.Docker](*image, dockerConfigExtra)\n\tskip, err := tmpl.New(ctx).Apply(docker.SkipPush)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif strings.TrimSpace(skip) == \"true\" {\n\t\treturn pipe.Skip(\"docker.skip_push is set: \" + image.Name)\n\t}\n\tif strings.TrimSpace(skip) == \"auto\" && ctx.Semver.Prerelease != \"\" {","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/goreleaser/goreleaser/blob/f5edd7395693c0c6b501dc722d445d2e86af854d/internal/pipe/docker/docker.go#L347-L383","documentation":"docker.build_flag_templates are Go templates applied before invoking docker buildx build; the rendered strings become build flags. This error means one template failed to evaluate, so goreleaser cannot construct the docker build command. The failing template text is embedded in the message.","triggerScenarios":"A build_flags entry templated with a key absent from the context, or containing invalid template syntax; commonly used with --build-arg flags like KEY={{ .Env.SOMETHING }} where the env var handling template function errors.","commonSituations":"Referencing .Env vars not set (in strict contexts), misspelled fields, or copied build_flag_templates from docs that assume extra context fields.","solutions":["Fix the field name/syntax indicated by the wrapped error.","Replace unavailable context fields with literal values or environment lookups that exist.","Validate config with `goreleaser check` and dry-run with `goreleaser build --snapshot`."],"exampleFix":"// before\nbuild_flag_templates:\n  - \"--build-arg=VERSION={{ .BadField }}\"\n// after\nbuild_flag_templates:\n  - \"--build-arg=VERSION={{ .Version }}\"","handlingStrategy":"validation","validationCode":"for _, t := range cfg.BuildFlagTemplates {\n    if _, err := tmpl.New(ctx).Apply(t); err != nil {\n        return fmt.Errorf(\"bad build flag template %q: %w\", t, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil { /* not applicable; wrap release() */ }\n}()\nif err := release(); err != nil && strings.Contains(err.Error(), \"build flag template\") {\n    // correct the template in goreleaser.yaml\n}","preventionTips":["Validate templates with a snapshot build before tagging","Avoid referencing .Env fields not guaranteed present","Quote build args carefully (--build-arg=K={{ .Version }})"],"tags":["docker","template","build-flags"],"backgroundTag":"template-execution-failed","analyzedSha":"f5edd7395693c0c6b501dc722d445d2e86af854d","analyzedAt":"2026-09-05T09:57:18.807Z","contentChangedAt":"2026-09-05T09:57:18.807Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}