argoproj/argo-workflows · error
failed to parse TypeMeta: %w
Error message
failed to parse TypeMeta: %w
What it means
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.
Source
Thrown at cmd/argo/commands/convert.go:93
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
}
}
return nil
}
func convertDocument(data []byte, outputFormat string, isJSON bool) error {
// First, determine the kind
var typeMeta metav1.TypeMeta
if err := yaml.Unmarshal(data, &typeMeta); err != nil {
return fmt.Errorf("failed to parse TypeMeta: %w", err)
}
var converted any
// Parse into legacy type and convert to current type
switch typeMeta.Kind {
case wf.CronWorkflowKind:
var legacy convert.LegacyCronWorkflow
if err := yaml.Unmarshal(data, &legacy); err != nil {
return fmt.Errorf("failed to parse CronWorkflow: %w", err)
}
converted = legacy.ToCurrent()
case wf.WorkflowKind:
var legacy convert.LegacyWorkflow
if err := yaml.Unmarshal(data, &legacy); err != nil {
return fmt.Errorf("failed to parse Workflow: %w", err)
}View on GitHub (pinned to 35bff19146)
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
Example fix
// before kind: 123 apiVersion: argoproj.io/v1alpha1 // after kind: Workflow apiVersion: argoproj.io/v1alpha1
Defensive patterns
Strategy: validation
Validate before calling
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 Try / catch
out=$(argo convert "$f" 2>&1) || {
case "$out" in
*"failed to parse TypeMeta"*) echo "doc is not a valid manifest object: $out" >&2;;
esac
} Prevention
- 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
When it happens
Trigger: `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).
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- error converting %s: %w
- failed to parse CronWorkflow: %w
- failed to parse Workflow: %w
- failed to parse WorkflowTemplate: %w
- no workflow found in given files
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/38e956654d6d2cd4.
Report an issue: GitHub.