argoproj/argo-workflows · error
ArtifactGCStrategy %q not valid
Error message
ArtifactGCStrategy %q not valid
What it means
artGCPodName maps an ArtifactGCStrategy to an abbreviation used in the GC pod name. Only OnWorkflowCompletion and OnWorkflowDeletion are valid; any other strategy value (including Undefined/empty) returns this error at workflow/controller/artifact_gc.go:267.
Source
Thrown at workflow/controller/artifact_gc.go:267
_, _ = h.Write([]byte(label))
_, _ = h.Write([]byte(labelValue))
}
sortedAnnotations := slices.Sorted(maps.Keys(info.podMetadata.Annotations))
for _, annotation := range sortedAnnotations {
annotationValue := info.podMetadata.Annotations[annotation]
_, _ = h.Write([]byte(annotation))
_, _ = h.Write([]byte(annotationValue))
}
var abbreviatedName string
switch strategy {
case wfv1.ArtifactGCOnWorkflowCompletion:
abbreviatedName = "wfcomp"
case wfv1.ArtifactGCOnWorkflowDeletion:
abbreviatedName = "wfdel"
default:
return "", fmt.Errorf("ArtifactGCStrategy %q not valid", strategy)
}
return fmt.Sprintf("%s-artgc-%s-%v", woc.wf.Name, abbreviatedName, h.Sum32()), nil
}
func (woc *wfOperationCtx) artGCTaskName(podName string, taskIndex int) string {
return fmt.Sprintf("%s-%d", podName, taskIndex)
}
func (woc *wfOperationCtx) artifactGCPodLabel(podName string) string {
hashedPod := fnv.New32a()
_, _ = hashedPod.Write([]byte(podName))
return fmt.Sprintf("%d", hashedPod.Sum32())
}
func (woc *wfOperationCtx) addTemplateArtifactsToTasks(ctx context.Context, podName string, tasks *[]*wfv1.WorkflowArtifactGCTask, template *wfv1.Template, artifactSearchResults wfv1.ArtifactSearchResults) {
if len(artifactSearchResults) == 0 {
returnView on GitHub (pinned to 35bff19146)
Solutions
- Fix the strategy value in the workflow spec: valid values are OnWorkflowCompletion and OnWorkflowDeletion under spec.artifactGC.strategies.
- Validate the workflow with argo lint before submitting to catch invalid strategy strings.
- Set a workflow-level default strategy (spec.artifactGC) so artifact-level lookups never resolve to Undefined.
- Check that the strategy never falls through to wfv1.ArtifactGCStrategyUndefined in your artifact annotations.
Example fix
// before
artifactGC:
strategies:
onCompletion: OnCompletion # invalid value
// after
artifactGC:
strategy: OnWorkflowCompletion # valid: OnWorkflowCompletion | OnWorkflowDeletion Defensive patterns
Strategy: validation
Validate before calling
strategy := wfv1.ArtifactGCStrategy("OnWorkflowCompletion") // validate before submit
if strategy != wfv1.ArtifactGCOnWorkflowCompletion && strategy != wfv1.ArtifactGCOnWorkflowDeletion {
return fmt.Errorf("invalid strategy %q", strategy)
}
// or simply: argo lint workflow.yaml Type guard
func validGCStrategy(s wfv1.ArtifactGCStrategy) bool {
return s == wfv1.ArtifactGCOnWorkflowCompletion || s == wfv1.ArtifactGCOnWorkflowDeletion
} Try / catch
if strings.Contains(err.Error(), "not valid") { /* fix strategy string in spec and resubmit */ } Prevention
- Always run argo lint before submitting workflows with artifact GC.
- Copy strategy names from the docs exactly: OnWorkflowCompletion, OnWorkflowDeletion.
- Set a workflow-level default strategy to avoid Undefined fallthrough.
When it happens
Trigger: An artifact's getArtifactGCStrategy resolves to a value outside the two valid strategies — e.g. an unset/empty strategy string, a typo'd strategy in YAML, or artifact-level strategies combined with workflow-level spec.artifactGC in a way that yields Undefined.
Common situations: Misspelling the strategy in YAML (e.g. strategy: OnCompletion instead of OnWorkflowCompletion); submitting a workflow where neither workflow-level nor artifact-level strategy is set but GC is somehow invoked; CRD schema changes between Argo versions.
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
- failure to create dynamic client: %w
- executor plugin metadata name is mandatory
- clientSecret empty
- failed to validate workflow template instanceid: %w
- malformed workflow template parameter "%s": valueFrom is nil
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/d330ed4b282595f3.
Report an issue: GitHub.