{"record":{"id":"5209c38396b25332","repo":"argoproj/argo-workflows","slug":"error-converting-s-w","errorCode":null,"errorMessage":"error converting %s: %w","messagePattern":"error converting (.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/convert.go","lineNumber":66,"sourceCode":"\t\t\treturn runConvert(cmd.Context(), args, output.String())\n\t\t},\n\t}\n\n\tcommand.Flags().VarP(&output, \"output\", \"o\", \"Output format. \"+output.Usage())\n\tcommand.Flags().BoolVar(&common.NoColor, \"no-color\", false, \"Disable colorized output\")\n\n\treturn command\n}\n\nvar yamlSeparator = regexp.MustCompile(`\\n---`)\n\nfunc runConvert(ctx context.Context, args []string, output string) error {\n\tfor _, file := range args {\n\t\terr := fileutil.WalkManifests(ctx, file, func(path string, data []byte) error {\n\t\t\tif jsonpkg.IsJSON(data) {\n\t\t\t\t// Parse single JSON document\n\t\t\t\tif err := convertDocument(data, output, true); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error converting %s: %w\", path, err)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Split YAML documents\n\t\t\t\tfor _, doc := range yamlSeparator.Split(string(data), -1) {\n\t\t\t\t\tdoc = strings.TrimSpace(doc)\n\t\t\t\t\tif doc == \"\" {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\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}","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/convert.go#L48-L84","documentation":"runConvert wraps any error returned by convertDocument for a JSON document with `error converting <path>` before propagating it out of the WalkManifests callback. The inner error (e.g. a parse failure) is preserved via %w. This is the JSON-document variant of the convert command's per-file error envelope.","triggerScenarios":"`argo convert file.json` (or a JSON manifest inside a walked directory) where the document is valid JSON but fails during conversion — e.g. TypeMeta parse error, or a malformed Workflow/CronWorkflow/WorkflowTemplate/ClusterWorkflowTemplate structure that yaml.Unmarshal rejects.","commonSituations":"JSON manifests exported with legacy singular `schedule`/`mutex`/`semaphore` fields and additional structural problems; hand-edited JSON with wrong nesting for the typed legacy structs; piping a JSON document that is actually a list/envelope rather than a single object.","solutions":["Read the wrapped inner error to see which field failed to parse, and fix the JSON at that path","Validate the manifest with `argo lint` before converting to catch structural issues with clearer messages","Ensure the document is a single API object with correct apiVersion/kind, not an array or wrapper","Split multi-object JSON (e.g. a List with items[]) into individual objects before converting"],"exampleFix":"// before (nested object unsupported)\n{\"items\":[{\"apiVersion\":\"argoproj.io/v1alpha1\",\"kind\":\"Workflow\",...}]}\n// after (single object per file)\n{\"apiVersion\":\"argoproj.io/v1alpha1\",\"kind\":\"Workflow\",\"metadata\":{...},\"spec\":{...}}","handlingStrategy":"validation","validationCode":"jq -e 'type == \"object\" and (.kind | type == \"string\") and (.apiVersion | type == \"string\")' file.json \\\n  || { echo 'not a single k8s manifest object'; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! argo convert \"$f\" -o json 2>conv.err; then\n  cat conv.err >&2   # envelope 'error converting <path>' + inner parse detail\nfi","preventionTips":["Ensure each JSON file holds exactly one API object, not a List or array","Validate with `argo lint` before converting","Keep manifests in git so conversion failures are diffable","Run conversions in CI to catch drift early"],"tags":["cli","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"}