goreleaser/goreleaser · error

input %q: invalid template: %w

Error message

input %q: invalid template: %w

What it means

The `input` of an SBOM configuration (the document to catalog, e.g. the archive or binary path) is rendered as a Go template and then made absolute. If the template cannot be applied, GoReleaser fails with `input %q: invalid template`. It wraps the underlying template error so the real cause is the inner message.

Source

Thrown at internal/pipe/sbom/sbom.go:305

		}
		extraEnvs = append(extraEnvs, renderedKeyValue)

		k, v, _ := strings.Cut(renderedKeyValue, "=")
		env[k] = v
	}

	var paths []string
	for idx, sbom := range cfg.Documents {
		input := expand(sbom, env)
		if !filepath.IsAbs(input) {
			// assume any absolute path is handled correctly and assume that any relative path is not already
			// adjusted to reference the dist path
			input = filepath.Join(ctx.Config.Dist, input)
		}

		path, err := templater.Apply(input)
		if err != nil {
			return nil, nil, nil, fmt.Errorf("input %q: invalid template: %w", input, err)
		}

		path, err = filepath.Abs(path)
		if err != nil {
			return nil, nil, nil, fmt.Errorf("unable to create artifact path %q: %w", sbom, err)
		}

		procPath, err := subprocessDistPath(ctx.Config.Dist, path)
		if err != nil {
			return nil, nil, nil, fmt.Errorf("cannot determine document path for %q: %w", path, err)
		}

		extraEnvs = appendExtraEnv(fmt.Sprintf("document%d", idx), procPath, extraEnvs, env)
		if idx == 0 {
			extraEnvs = appendExtraEnv("document", procPath, extraEnvs, env)
		}

		paths = append(paths, procPath)

View on GitHub (pinned to f5edd73956)

Solutions

  1. Correct the template expression in sboms.input, verifying field names against GoReleaser's template docs
  2. If the default input is fine, remove the custom input so GoReleaser uses `{{ .ArtifactPath }}`
  3. Run `goreleaser release --snapshot --debug` to see the wrapped template error detail

Example fix

// before
sboms:
  - artifacts: archive
    input: "{{ .ArtifactPathh }}"
// after
sboms:
  - artifacts: archive
    input: "{{ .ArtifactPath }}"
Defensive patterns

Strategy: validation

Validate before calling

// Validate custom sbom input templates before release
for _, s := range cfg.SBOMs {
	if s.Input != "" && strings.Contains(s.Input, "{{") {
		if _, err := tmpl.New(nil).Apply(s.Input); err != nil {
			return fmt.Errorf("bad sbom input %q: %w", s.Input, err)
		}
	}
}

Try / catch

if err != nil {
	var terr *template.Error
	if errors.As(err, &terr) {
		return fmt.Errorf("sbom input template error at line %d: %w", terr.Line(), terr)
	}
	return err
}

Prevention

When it happens

Trigger: The `input:` field of an sboms config contains template syntax that fails to render — bad syntax like `{{ .Version ` or a nonexistent field such as `{{.Artifact.Name}}` when not in scope.

Common situations: Overriding the default `{{ .ArtifactPath }}` input and making a typo; using fields only available in other pipes; quoting mistakes in YAML that inject stray braces.

Related errors


AI-assisted analysis of goreleaser/goreleaser@f5edd73956 (2026-09-05). Data as JSON: /api/errors/c598e5b1ea811582. Report an issue: GitHub.