{"record":{"id":"df2da10141846634","repo":"argoproj/argo-workflows","slug":"failed-to-convert-to-workflow-from-unstructured","errorCode":null,"errorMessage":"failed to convert to workflow from unstructured: %w","messagePattern":"failed to convert to workflow from unstructured: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/controller/controller.go","lineNumber":1397,"sourceCode":"\t\t\tif wf != nil {\n\t\t\t\twfc.metrics.DeleteRealtimeMetricsForWfUID(string(wf.GetUID()))\n\t\t\t}\n\t\t},\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc (wfc *WorkflowController) archiveWorkflowAux(ctx context.Context, obj any) error {\n\tun, ok := obj.(*unstructured.Unstructured)\n\tif !ok {\n\t\treturn nil\n\t}\n\twf, err := util.FromUnstructured(un)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to convert to workflow from unstructured: %w\", err)\n\t}\n\terr = wfc.hydrator.Hydrate(ctx, wf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to hydrate workflow: %w\", err)\n\t}\n\tlogger := logging.RequireLoggerFromContext(ctx)\n\tlogger.WithFields(logging.Fields{\"namespace\": wf.Namespace, \"workflow\": wf.Name, \"uid\": wf.UID}).Info(ctx, \"archiving workflow\")\n\terr = wfc.wfArchive.ArchiveWorkflow(ctx, wf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to archive workflow: %w\", err)\n\t}\n\tdata, err := json.Marshal(map[string]any{\n\t\t\"metadata\": metav1.ObjectMeta{\n\t\t\tLabels: map[string]string{\n\t\t\t\tcommon.LabelKeyWorkflowArchivingStatus: \"Archived\",\n\t\t\t},\n\t\t},\n\t})","sourceCodeStart":1379,"sourceCodeEnd":1415,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/controller/controller.go#L1379-L1415","documentation":"In archiveWorkflowAux (workflow/controller/controller.go:1397), the completed-workflow archiving path converts the unstructured informer object into a typed *wfv1.Workflow via util.FromUnstructured; if the conversion (including spec validation) fails, this wrapped error is returned. It means the object that just completed does not deserialize/validate as a valid Workflow.","triggerScenarios":"A workflow object on workflow-completion (added to the archive queue) cannot be converted from unstructured — corrupted or non-conforming Workflow CR in the cluster, an object written by an incompatible/newer schema version, or a malformed CR applied manually.","commonSituations":"CRD/schema version skew (controller older than objects written by a newer Argo version); hand-edited workflow resources; validation rules tightened in util.FromUnstructured so legacy objects no longer pass.","solutions":["Check the wrapped inner error for the exact schema/validation failure and fix the offending workflow fields.","Align controller and CRD versions (upgrade both together); re-apply the matching CRDs from the same release.","Delete/recreate the malformed workflow if its content is unrecoverable; archiving is skipped but the workflow is not blocked from deletion.","Run `argo lint` on the workflow spec to reproduce the validation error outside the controller."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the workflow spec before submitting so completion-time conversion can't fail\nwf := wfv1.Workflow{}\nif err := json.Unmarshal(raw, &wf); err != nil { return err }\nif err := wf.Validate(ctx, validate.DefaultOpts); err != nil { return err }\n// or: argo lint my-workflow.yaml","typeGuard":null,"tryCatchPattern":"wf, err := util.FromUnstructured(un)\nif err != nil {\n    return fmt.Errorf(\"failed to convert to workflow from unstructured: %w\", err)\n}","preventionTips":["Keep controller and CRD versions in lockstep (re-apply CRDs on every upgrade)","Never hand-edit Workflow CRs; submit via `argo submit` or validated manifests","Run `argo lint` on workflow definitions before submitting","Test cross-version upgrades in staging to catch schema skew"],"tags":["kubernetes","validation","schema","archiving"],"backgroundTag":"schema-validation-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"}