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
- Use one of the supported variants exactly: 'Tags', 'CommitSha', or 'AbbrevCommitSha' (case-insensitive)
- Check the Skaffold docs/schema for your version — variant names may differ across releases
- Remove the variant field to use the default variant
- 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
- Use exact variant names from your Skaffold version's docs
- Validate skaffold.yaml against its JSON schema in CI
- Pin Skaffold version and check changelog for tagger variant renames
- Omit variant to accept the default
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
- bad timezone provided: %q, error: %s
- parsing template: %w
- unable to find git commit: %w
- getting git status: %w
- CONFIG_REMOTE_REPO_CACHE_NOT_FOUND_ERR
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/87302fbcc34f0b6e.
Report an issue: GitHub.