{"record":{"id":"38e956654d6d2cd4","repo":"argoproj/argo-workflows","slug":"failed-to-parse-typemeta-w","errorCode":null,"errorMessage":"failed to parse TypeMeta: %w","messagePattern":"failed to parse TypeMeta: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/convert.go","lineNumber":93,"sourceCode":"\t\t\t\t\tif err := convertDocument([]byte(doc), output, false); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"error converting %s: %w\", path, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc convertDocument(data []byte, outputFormat string, isJSON bool) error {\n\t// First, determine the kind\n\tvar typeMeta metav1.TypeMeta\n\tif err := yaml.Unmarshal(data, &typeMeta); err != nil {\n\t\treturn fmt.Errorf(\"failed to parse TypeMeta: %w\", err)\n\t}\n\n\tvar converted any\n\n\t// Parse into legacy type and convert to current type\n\tswitch typeMeta.Kind {\n\tcase wf.CronWorkflowKind:\n\t\tvar legacy convert.LegacyCronWorkflow\n\t\tif err := yaml.Unmarshal(data, &legacy); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse CronWorkflow: %w\", err)\n\t\t}\n\t\tconverted = legacy.ToCurrent()\n\n\tcase wf.WorkflowKind:\n\t\tvar legacy convert.LegacyWorkflow\n\t\tif err := yaml.Unmarshal(data, &legacy); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse Workflow: %w\", err)\n\t\t}","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/convert.go#L75-L111","documentation":"convertDocument first unmarshals only the TypeMeta (apiVersion/kind) with sigs.k8s.io/yaml to decide which legacy type to convert. If even that lightweight unmarshal fails, the document is not parseable into a k8s-style object at all and this error is returned.","triggerScenarios":"`argo convert` given a document whose YAML is syntactically invalid, whose top level is not a mapping (e.g. a bare list, scalar, or empty doc), or where apiVersion/kind have non-string values (e.g. kind: 123).","commonSituations":"Feeding non-manifest text (README, log output) to `argo convert`; a ConfigMap/Secret doc with binary or numeric data blocking TypeMeta decode; documents starting with BOM or containing tabs; converting a file where the first `---` chunk is a comment-only fragment that decodes to a non-map.","solutions":["Fix the YAML/JSON syntax error reported in the wrapped message (check tabs, indentation, non-string kind/apiVersion)","Ensure each document is a top-level mapping with string apiVersion/kind — arbitrary docs pass through only if TypeMeta can be decoded","Remove or convert non-workflow documents (Lists, bare arrays) before running `argo convert`","Re-encode the file (strip BOM, convert to UTF-8, LF line endings) and retry"],"exampleFix":"// before\nkind: 123\napiVersion: argoproj.io/v1alpha1\n// after\nkind: Workflow\napiVersion: argoproj.io/v1alpha1","handlingStrategy":"validation","validationCode":"python3 -c \"import yaml,sys; d=yaml.safe_load(open(sys.argv[1])); assert isinstance(d,dict) and isinstance(d.get('kind'),str) and isinstance(d.get('apiVersion'),str), 'bad TypeMeta'\" file.yaml","typeGuard":null,"tryCatchPattern":"out=$(argo convert \"$f\" 2>&1) || {\n  case \"$out\" in\n    *\"failed to parse TypeMeta\"*) echo \"doc is not a valid manifest object: $out\" >&2;;\n  esac\n}","preventionTips":["Feed argo convert only manifest files with string kind/apiVersion at top level","Strip BOM and normalize to UTF-8/LF before converting","Skip non-manifest documents in multi-doc files (comments-only chunks)","Keep converters out of generic file pipelines that may pass arbitrary text"],"tags":["cli","yaml","json","manifests","argoproj"],"backgroundTag":"manifest-parse-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"}