mikefarah/yq · error
failed to load %v: %w
Error message
failed to load %v: %w
What it means
loadString resolved a filename and called loadString(filename) to read it, but the read/parse of that file failed. The %w wraps the underlying cause — commonly the file does not exist, is unreadable, or its contents could not be parsed as the expected format; the offending filename is printed in the message.
Source
Thrown at pkg/yqlib/operator_load.go:88
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
rhs, err := d.GetMatchingNodes(context.SingleReadonlyChildContext(candidate), expressionNode.RHS)
if err != nil {
return Context{}, err
}
if rhs.MatchingNodes.Front() == nil {
return Context{}, fmt.Errorf("filename expression returned nil")
}
nameCandidateNode := rhs.MatchingNodes.Front().Value.(*CandidateNode)
filename := nameCandidateNode.Value
contentsCandidate, err := loadString(filename)
if err != nil {
return Context{}, fmt.Errorf("failed to load %v: %w", filename, err)
}
results.PushBack(contentsCandidate)
}
return context.ChildContext(results), nil
}
func loadOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
log.Debugf("loadOperator")
if ConfiguredSecurityPreferences.DisableFileOps {
return Context{}, fmt.Errorf("file operations have been disabled")
}
loadPrefs := expressionNode.Operation.Preferences.(loadPrefs)
// need to evaluate the 1st parameter against the contextView on GitHub (pinned to 8b5af0694b)
Solutions
- Check the printed filename exists and is readable
- Correct the path — it is interpreted literally as given
- Ensure the target file's content is valid for its format
- Verify the process has permission to read the file
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/yqlib/operator_load.go:88 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mikefarah/yq@8b5af0694b (2026-09-05).
Data as JSON: /api/errors/2acdf78f08619ee8.
Report an issue: GitHub.