argoproj/argo-workflows · error
error converting %s: %w
Error message
error converting %s: %w
What it means
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.
Source
Thrown at cmd/argo/commands/convert.go:66
return runConvert(cmd.Context(), args, output.String())
},
}
command.Flags().VarP(&output, "output", "o", "Output format. "+output.Usage())
command.Flags().BoolVar(&common.NoColor, "no-color", false, "Disable colorized output")
return command
}
var yamlSeparator = regexp.MustCompile(`\n---`)
func runConvert(ctx context.Context, args []string, output string) error {
for _, file := range args {
err := fileutil.WalkManifests(ctx, file, func(path string, data []byte) error {
if jsonpkg.IsJSON(data) {
// Parse single JSON document
if err := convertDocument(data, output, true); err != nil {
return fmt.Errorf("error converting %s: %w", path, err)
}
} else {
// Split YAML documents
for _, doc := range yamlSeparator.Split(string(data), -1) {
doc = strings.TrimSpace(doc)
if doc == "" {
continue
}
if err := convertDocument([]byte(doc), output, false); err != nil {
return fmt.Errorf("error converting %s: %w", path, err)
}
}
}
return nil
})
if err != nil {
return err
}View on GitHub (pinned to 35bff19146)
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
Example fix
// before (nested object unsupported)
{"items":[{"apiVersion":"argoproj.io/v1alpha1","kind":"Workflow",...}]}
// after (single object per file)
{"apiVersion":"argoproj.io/v1alpha1","kind":"Workflow","metadata":{...},"spec":{...}} Defensive patterns
Strategy: validation
Validate before calling
jq -e 'type == "object" and (.kind | type == "string") and (.apiVersion | type == "string")' file.json \
|| { echo 'not a single k8s manifest object'; exit 1; } Try / catch
if ! argo convert "$f" -o json 2>conv.err; then cat conv.err >&2 # envelope 'error converting <path>' + inner parse detail fi
Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- failed to parse TypeMeta: %w
- unknown output mode: %s
- failed to get existing cluster workflow template %q to updat
- failed to update cluster workflow template: %s, %w
- invalid shell %q: supported shells are bash, zsh, and fish
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/5209c38396b25332.
Report an issue: GitHub.