argoproj/argo-workflows · error
failed to unmarshal JSON %q: %w
Error message
failed to unmarshal JSON %q: %w
What it means
MustUnmarshal detected leading '{' so treated the input as JSON, but json.Unmarshal failed. The message includes the offending text; MustUnmarshal panics with this wrapped error, signalling malformed JSON passed to a test/dev helper.
Source
Thrown at pkg/apis/workflow/v1alpha1/marshall.go:33
func MustUnmarshal(text, v any) {
switch x := text.(type) {
case string:
MustUnmarshal([]byte(x), v)
case []byte:
if len(x) == 0 {
panic("no text to unmarshal")
}
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)
}View on GitHub (pinned to 35bff19146)
Solutions
- Fix the JSON syntax (quotes, commas, brackets) in the input
- Pass valid YAML (non-'{' leading) or a file reference instead
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/apis/workflow/v1alpha1/marshall.go:33 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/b5a1c46694dbee4d.
Report an issue: GitHub.