{"record":{"id":"b80e657df06860a4","repo":"argoproj/argo-workflows","slug":"failed-to-mark-the-workflow-archived-w","errorCode":null,"errorMessage":"failed to mark the workflow archived: %w","messagePattern":"failed to mark the workflow archived: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/controller/controller.go","lineNumber":1432,"sourceCode":"\t\t},\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to marshal patch: %w\", err)\n\t}\n\t_, err = wfc.wfclientset.ArgoprojV1alpha1().Workflows(un.GetNamespace()).Patch(\n\t\tctx,\n\t\tun.GetName(),\n\t\ttypes.MergePatchType,\n\t\tdata,\n\t\tmetav1.PatchOptions{},\n\t)\n\tif err != nil {\n\t\t// from this point on we have successfully archived the workflow, and it is possible for the workflow to have actually\n\t\t// been deleted, so it's not a problem to get a `IsNotFound` error\n\t\tif apierr.IsNotFound(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"failed to mark the workflow archived: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (wfc *WorkflowController) instanceIDReq() labels.Requirement {\n\treturn util.InstanceIDRequirement(wfc.Config.InstanceID)\n}\n\nfunc (wfc *WorkflowController) newTypedConfigMapInformer(ctx context.Context) cache.SharedIndexInformer {\n\tindexInformer := v1.NewFilteredConfigMapInformer(wfc.kubeclientset, wfc.GetManagedNamespace(), configMapResyncPeriod, cache.Indexers{\n\t\tindexes.ConfigMapLabelsIndex: indexes.ConfigMapIndexFunc,\n\t}, func(opts *metav1.ListOptions) {\n\t\topts.LabelSelector = common.LabelKeyConfigMapType\n\t})\n\t//nolint:errcheck // the error only happens if the informer was already started, and it hasn't been\n\tindexInformer.SetTransform(informerutil.StripManagedFields)\n\tctx, logger := logging.RequireLoggerFromContext(ctx).WithField(\"component\", \"config_map_informer\").InContext(ctx)\n\tlogger.WithField(\"executorPlugins\", wfc.executorPlugins != nil).Info(ctx, \"Plugins\")","sourceCodeStart":1414,"sourceCodeEnd":1450,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/controller/controller.go#L1414-L1450","documentation":"Final step of archiveWorkflowAux (workflow/controller/controller.go:1432): after the workflow was archived to the DB, the controller patches the live Workflow with the Archived label. If the patch call fails with anything other than NotFound, this wrapped error is returned. NotFound is deliberately tolerated because the workflow may have been deleted after archiving succeeded. Consequence on failure: the workflow is archived but its label still says NotArchived, so the archived-workflow GC may re-process it.","triggerScenarios":"Patch(ctx, name, MergePatchType, data, ...) fails with a non-NotFound API error — RBAC denial on workflows patch, API-server outage/timeout, Conflict from a concurrent update (rare for merge patches), or the workflow was deleted by a finalizer-blocked/failed delete returning an error other than 404.","commonSituations":"Tightened RBAC on the controller service account (patch on argoproj.io/workflows removed); API server flakiness during mass workflow completion; webhook/finalizer making the patch fail while the object still exists.","solutions":["Check the wrapped API error: if Forbidden, restore the controller's RBAC patch permission on workflows.argoproj.io.","If the workflow was truly deleted (404 with different cause), no action needed — the archiving itself already succeeded.","Verify the workflow's archiving-status label (kubectl get wf <name> -o jsonpath='{.metadata.labels.workflows\\.argoproj\\.io\\/archiving-status}') and re-trigger archiving if stuck at NotArchived; the periodic archived-workflow GC re-queues such workflows.","Fix any blocking finalizer or validating webhook rejecting patches on completed workflows."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight RBAC check for the controller service account\nkubectl auth can-i patch workflows.argoproj.io --as=system:serviceaccount:argo:workflow-controller -n <ns>","typeGuard":null,"tryCatchPattern":"_, err := wfc.wfclientset.ArgoprojV1alpha1().Workflows(ns).Patch(ctx, name, types.MergePatchType, data, metav1.PatchOptions{})\nif err != nil {\n    if apierr.IsNotFound(err) {\n        return nil // workflow deleted after successful archive: acceptable\n    }\n    return fmt.Errorf(\"failed to mark the workflow archived: %w\", err)\n}","preventionTips":["Grant the controller patch on workflows.argoproj.io in all managed namespaces","Check workflows.argoproj.io/archiving-status labels to spot stuck NotArchived workflows","Remove blocking finalizers/webhooks from completed workflows","Rely on the periodic archived-workflow GC to re-queue unmarked workflows"],"tags":["kubernetes","patch","rbac","archiving"],"backgroundTag":"workflow-patch-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}