argoproj/argo-workflows · warning

failed to get WorkflowArtifactGCTask by key %q: %w

Error message

failed to get WorkflowArtifactGCTask by key %q: %w

What it means

getArtifactTask looks up a WorkflowArtifactGCTask CR by namespace/name key in the controller's informer cache. GetByKey only errors if the informer's indexer itself fails; this wraps that low-level cache error at workflow/controller/artifact_gc.go:349. It does not mean the task is missing (that returns nil, nil).

Source

Thrown at workflow/controller/artifact_gc.go:349

		if !found {
			artifactsByNode[artifactSearchResult.NodeID] = wfv1.ArtifactNodeSpec{
				ArchiveLocation: archiveLocation,
				Artifacts:       make(map[string]wfv1.Artifact),
			}
			artifactNodeSpec = artifactsByNode[artifactSearchResult.NodeID]
		}

		artifactNodeSpec.Artifacts[artifactSearchResult.Name] = artifactSearchResult.Artifact
	}
	woc.log.WithFields(logging.Fields{"template": template.Name, "task": currentTask.Name, "artifacts": artifactsByNode}).Debug(ctx, "list of artifacts pertaining to template")
}

// find WorkflowArtifactGCTask CRD object by name
func (woc *wfOperationCtx) getArtifactTask(taskName string) (*wfv1.WorkflowArtifactGCTask, error) {
	key := woc.wf.Namespace + "/" + taskName
	task, exists, err := woc.controller.artGCTaskInformer.Informer().GetIndexer().GetByKey(key)
	if err != nil {
		return nil, fmt.Errorf("failed to get WorkflowArtifactGCTask by key %q: %w", key, err)
	}
	if !exists {
		return nil, nil
	}
	return task.(*wfv1.WorkflowArtifactGCTask), nil
}

// create WorkflowArtifactGCTask CRD object
func (woc *wfOperationCtx) createWorkflowArtifactGCTask(ctx context.Context, task *wfv1.WorkflowArtifactGCTask) (*wfv1.WorkflowArtifactGCTask, error) {
	// first make sure it doesn't already exist
	foundTask, err := woc.getArtifactTask(task.Name)
	if err != nil {
		return nil, err
	}
	if foundTask != nil {
		woc.log.WithField("task", task.Name).Debug(ctx, "Artifact GC Task already exists")
	} else {
		woc.log.WithField("task", task.Name).Info(ctx, "Creating Artifact GC Task")

View on GitHub (pinned to 35bff19146)

Solutions

  1. Check controller logs for informer sync errors around the time of the failure; restart the workflow-controller if the cache is wedged.
  2. Verify woc.wf.Namespace and the generated task name are non-empty in the log line for this error.
  3. Confirm the WorkflowArtifactGCTask CRD is installed and the informer has started (controller logs 'Artifact GC Task' informer readiness).
  4. The reconciliation is requeued automatically; if transient API issues caused it, no action is needed beyond ensuring API server health.
Defensive patterns

Strategy: retry

Try / catch

if strings.Contains(err.Error(), "failed to get WorkflowArtifactGCTask by key") { /* transient cache error: rely on controller requeue; restart controller if persistent */ }

Prevention

When it happens

Trigger: The threadSafeStore indexer returns a non-nil error — practically only on empty/invalid keys (e.g. empty task name or namespace) or corrupted informer state after a cache resync failure.

Common situations: Controller starting up with a misconfigured informer; a bug producing an empty taskName; severe API-server/watch disruption causing informer re-init concurrent with reconciliation.

Related errors


AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03). Data as JSON: /api/errors/ee1ddb4c0e4d024d. Report an issue: GitHub.