{"record":{"id":"c154795c43522167","repo":"argoproj/argo-workflows","slug":"failed-to-parse-unknown-kind-s-w","errorCode":null,"errorMessage":"failed to parse unknown kind %s: %w","messagePattern":"failed to parse unknown kind (.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/convert.go","lineNumber":133,"sourceCode":"\t\tvar legacy convert.LegacyWorkflowTemplate\n\t\tif err := yaml.Unmarshal(data, &legacy); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse WorkflowTemplate: %w\", err)\n\t\t}\n\t\tconverted = legacy.ToCurrent()\n\n\tcase wf.ClusterWorkflowTemplateKind:\n\t\tvar legacy convert.LegacyClusterWorkflowTemplate\n\t\tif err := yaml.Unmarshal(data, &legacy); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse ClusterWorkflowTemplate: %w\", err)\n\t\t}\n\t\tconverted = legacy.ToCurrent()\n\n\tdefault:\n\t\t// Unknown type - pass through unchanged\n\t\t// Re-parse as generic map to preserve structure\n\t\tvar generic map[string]any\n\t\tif err := yaml.Unmarshal(data, &generic); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse unknown kind %s: %w\", typeMeta.Kind, err)\n\t\t}\n\t\tconverted = generic\n\t}\n\n\treturn outputObject(converted, outputFormat, isJSON)\n}\n\nfunc outputObject(obj any, format string, preferJSON bool) error {\n\tvar outBytes []byte\n\tvar err error\n\n\t// Output JSON if format is \"json\", or if input was JSON and format is not explicitly \"yaml\"\n\t// This preserves input format by default while allowing explicit format override\n\toutputJSON := format == \"json\" || (preferJSON && format != \"yaml\")\n\n\tif outputJSON {\n\t\toutBytes, err = json.Marshal(obj)\n\t\tif err != nil {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/convert.go#L115-L151","documentation":"During `argo convert`, a document with a kind not among the known legacy kinds (Workflow, CronWorkflow, WorkflowTemplate, ClusterWorkflowTemplate) falls through to the default branch and is re-parsed as a generic map for passthrough. This error means even that generic `map[string]any` unmarshal failed, i.e. the document is not structurally valid YAML/JSON at all, independent of kind.","triggerScenarios":"`argo convert` given a document whose kind is unrecognized (or empty) AND whose content is not parseable into a YAML object mapping: invalid YAML syntax, tabs in indentation, top-level scalars or lists instead of a mapping, duplicate keys rejected by the parser.","commonSituations":"Passing non-YAML files (binaries, plain text, empty files) to convert; a multi-document file where a later document is malformed; files with kind typos like \"WorkflowTemplates\" that skip the known-kind branches and then hit deeper syntax errors.","solutions":["Fix the YAML syntax error reported by the wrapped error (check indentation, tabs, and that the top level is a mapping).","Run `argo convert` with `--format json`/lint tooling to isolate the malformed document in a multi-doc file.","If the kind is a typo of a known kind, correct the `kind:` field so the proper legacy struct handles it.","Verify the input file is not empty, truncated, or binary."],"exampleFix":"# before (top-level list, not a mapping)\n- name: main\n  template: whalesay\n# after\napiVersion: argoproj.io/v1alpha1\nkind: Workflow\nmetadata:\n  name: main-wf\nspec:\n  templates:\n    - name: main\n      template: whalesay","handlingStrategy":"validation","validationCode":"// pre-parse as a mapping and check kind before converting\nvar doc map[string]any\nif err := yaml.Unmarshal(data, &doc); err != nil {\n  return fmt.Errorf(\"not valid YAML mapping: %w\", err)\n}\nif _, ok := doc[\"kind\"]; !ok { return errors.New(\"missing kind\") }","typeGuard":null,"tryCatchPattern":"if err := convertDocument(data, out, isJSON); err != nil {\n  if strings.Contains(err.Error(), \"failed to parse unknown kind\") {\n    log.Printf(\"skipping unparseable non-argo document\")\n    return nil\n  }\n  return err\n}","preventionTips":["Validate every document in multi-doc files individually before batch conversion.","Ensure the top level of each document is a mapping with apiVersion/kind.","Never pass non-YAML files to `argo convert`."],"tags":["cli","yaml","parsing","conversion"],"backgroundTag":"yaml-unmarshal-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"}