argoproj/argo-workflows · error
cannot unmarshal type %T
Error message
cannot unmarshal type %T
What it means
MustUnmarshal accepts only byte slices and strings (optionally prefixed with '@file', '{' for JSON); any other Go type passed as text reaches this panic in the default branch. It is a programmer-error guard for callers of MustUnmarshal (e.g. template expression handling) that pass an unsupported type such as an int or a struct; it panics rather than returning an error.
Source
Thrown at pkg/apis/workflow/v1alpha1/marshall.go:41
switch x[0] {
case '@':
filename := string(x[1:])
y, err := os.ReadFile(filepath.Clean(filename))
if err != nil {
panic(fmt.Errorf("failed to read file %s: %w", filename, err))
}
MustUnmarshal(y, v)
case '{':
if err := json.Unmarshal(x, v); err != nil {
panic(fmt.Errorf("failed to unmarshal JSON %q: %w", string(x), err))
}
default:
if err := yaml.UnmarshalStrict(x, v); err != nil {
panic(fmt.Errorf("failed to unmarshal YAML %q: %w", string(x), err))
}
}
default:
panic(fmt.Errorf("cannot unmarshal type %T", text))
}
}
func MustMarshallJSON(v any) string {
data, err := json.Marshal(v)
if err != nil {
panic(err)
}
return string(data)
}
func MustUnmarshalClusterWorkflowTemplate(text any) *ClusterWorkflowTemplate {
x := &ClusterWorkflowTemplate{}
MustUnmarshal(text, &x)
return x
}
func MustUnmarshalCronWorkflow(text any) *CronWorkflow {View on GitHub (pinned to 35bff19146)
Solutions
- Pass a string or []byte to MustUnmarshal
- Convert the value (e.g. fmt.Sprint) before calling
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at pkg/apis/workflow/v1alpha1/marshall.go:41 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/99dbe9bfbce50366.
Report an issue: GitHub.