argoproj/argo-workflows · error
failed to read file %s: %w
Error message
failed to read file %s: %w
What it means
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.
Source
Thrown at pkg/apis/workflow/v1alpha1/marshall.go:28
)
// MustUnmarshal is a utility function to unmarshall either a file, byte array, or string of JSON or YAMl into a object.
// 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
// v - a pointer to an object
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)View on GitHub (pinned to 35bff19146)
Solutions
- Ensure the referenced file path (after the @) exists
- Fix the path in the @-prefixed argument or embed the YAML/JSON inline instead
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/apis/workflow/v1alpha1/marshall.go:28 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/ee32f55688150775.
Report an issue: GitHub.