GoogleContainerTools/skaffold · error

%q is not a valid git tagger variant

Error message

%q is not a valid git tagger variant

What it means

The gitCommit Tagger supports a fixed set of variants (e.g. Tags, CommitSha, AbbrevCommitSha) that select which `git` command determines the tag source. NewGitCommit looks the variant up in the variants map (case-insensitively); an unknown variant string means the tagger cannot be constructed, so it returns this error immediately.

Source

Thrown at pkg/skaffold/tag/git_commit.go:54

	runGitFn      func(context.Context, string) (string, error)
	ignoreChanges bool
}

var variants = map[string]func(context.Context, string) (string, error){
	"":                gitTags,
	"tags":            gitTags,
	"commitsha":       gitCommitsha,
	"abbrevcommitsha": gitAbbrevcommitsha,
	"treesha":         gitTreesha,
	"abbrevtreesha":   gitAbbrevtreesha,
	"branches":        gitBranches,
}

// NewGitCommit creates a new git commit tagger. It fails if the tagger variant is invalid.
func NewGitCommit(prefix, variant string, ignoreChanges bool) (*GitCommit, error) {
	runGitFn, found := variants[strings.ToLower(variant)]
	if !found {
		return nil, fmt.Errorf("%q is not a valid git tagger variant", variant)
	}

	return &GitCommit{
		prefix:        prefix,
		runGitFn:      runGitFn,
		ignoreChanges: ignoreChanges,
	}, nil
}

// GenerateTag generates a tag from the git commit.
func (t *GitCommit) GenerateTag(ctx context.Context, image latest.Artifact) (string, error) {
	ref, err := t.runGitFn(ctx, image.Workspace)
	if err != nil {
		return "", fmt.Errorf("unable to find git commit: %w", err)
	}

	ref = sanitizeTag(ref)

View on GitHub (pinned to a1189de023)

Solutions

  1. Use one of the supported variants exactly: 'Tags', 'CommitSha', or 'AbbrevCommitSha' (case-insensitive)
  2. Check the Skaffold docs/schema for your version — variant names may differ across releases
  3. Remove the variant field to use the default variant
  4. Validate skaffold.yaml against the JSON schema (skaffold init / IDE schema validation) to catch typos early

Example fix

// before
{"tagger": {"git_Commit": {"variant": "sha"}}}
// after
{"tagger": {"git_Commit": {"variant": "CommitSha"}}}
Defensive patterns

Strategy: validation

Validate before calling

var validVariants = map[string]bool{"tags": true, "commitsha": true, "abbrevcommitsha": true}
if !validVariants[strings.ToLower(cfg.Tagger.GitCommit.Variant)] {
    return fmt.Errorf("unsupported gitCommit variant %q", cfg.Tagger.GitCommit.Variant)
}

Type guard

func validGitVariant(v string) bool {
    switch strings.ToLower(v) {
    case "tags", "commitsha", "abbrevcommitsha":
        return true
    }
    return false
}

Try / catch

gc, err := tag.NewGitCommit(prefix, variant, false)
if err != nil {
    return fmt.Errorf("bad tagger config (check variant in skaffold.yaml): %w", err)
}

Prevention

When it happens

Trigger: Calling NewGitCommit(prefix, "commitsha-typo", false) or configuring tagger.git_Commit.variant in skaffold.yaml with a value not present in the variants map (e.g. 'sha' instead of 'CommitSha', or a misspelled 'abbrevCommitSha').

Common situations: Copy-pasting tagger config from older Skaffold docs where variant names changed; typos in skaffold.yaml; YAML enum values written in an unexpected casing that still fails because the name simply doesn't exist.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/87302fbcc34f0b6e. Report an issue: GitHub.