{"record":{"id":"b5a1c46694dbee4d","repo":"argoproj/argo-workflows","slug":"failed-to-unmarshal-json-q-w","errorCode":null,"errorMessage":"failed to unmarshal JSON %q: %w","messagePattern":"failed to unmarshal JSON %q: %w","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apis/workflow/v1alpha1/marshall.go","lineNumber":33,"sourceCode":"func MustUnmarshal(text, v any) {\n\tswitch x := text.(type) {\n\tcase string:\n\t\tMustUnmarshal([]byte(x), v)\n\tcase []byte:\n\t\tif len(x) == 0 {\n\t\t\tpanic(\"no text to unmarshal\")\n\t\t}\n\t\tswitch x[0] {\n\t\tcase '@':\n\t\t\tfilename := string(x[1:])\n\t\t\ty, err := os.ReadFile(filepath.Clean(filename))\n\t\t\tif err != nil {\n\t\t\t\tpanic(fmt.Errorf(\"failed to read file %s: %w\", filename, err))\n\t\t\t}\n\t\t\tMustUnmarshal(y, v)\n\t\tcase '{':\n\t\t\tif err := json.Unmarshal(x, v); err != nil {\n\t\t\t\tpanic(fmt.Errorf(\"failed to unmarshal JSON %q: %w\", string(x), err))\n\t\t\t}\n\t\tdefault:\n\t\t\tif err := yaml.UnmarshalStrict(x, v); err != nil {\n\t\t\t\tpanic(fmt.Errorf(\"failed to unmarshal YAML %q: %w\", string(x), err))\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"cannot unmarshal type %T\", text))\n\t}\n}\n\nfunc MustMarshallJSON(v any) string {\n\tdata, err := json.Marshal(v)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn string(data)\n}","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/pkg/apis/workflow/v1alpha1/marshall.go#L15-L51","documentation":"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.","triggerScenarios":"Thrown at pkg/apis/workflow/v1alpha1/marshall.go:33 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the JSON syntax (quotes, commas, brackets) in the input","Pass valid YAML (non-'{' leading) or a file reference instead"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}