{"record":{"id":"ee32f55688150775","repo":"argoproj/argo-workflows","slug":"failed-to-read-file-s-w","errorCode":null,"errorMessage":"failed to read file %s: %w","messagePattern":"failed to read file (.+?): %w","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apis/workflow/v1alpha1/marshall.go","lineNumber":28,"sourceCode":")\n\n// MustUnmarshal is a utility function to unmarshall either a file, byte array, or string of JSON or YAMl into a object.\n// text - a byte array or string, if starts with \"@\" it assumed to be a file and read from disk, is starts with \"{\" assumed to be JSON, otherwise assumed to be YAML\n// v - a pointer to an object\nfunc 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)","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/pkg/apis/workflow/v1alpha1/marshall.go#L10-L46","documentation":"MustUnmarshal was given text starting with '@' (a file reference) and os.ReadFile failed for that path. Because this is the Must* helper, the error is raised as a panic — it indicates developer/test misuse or a missing fixture file, not user input.","triggerScenarios":"Thrown at pkg/apis/workflow/v1alpha1/marshall.go:28 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the referenced file path (after the @) exists","Fix the path in the @-prefixed argument or embed the YAML/JSON inline 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"}