mikefarah/yq · error

file operations have been disabled

Error message

file operations have been disabled

What it means

loadString (and load) checked ConfiguredSecurityPreferences.DisableFileOps and found file operations switched off — a hard security sentinel. The evaluation never touches the filesystem; the operator is unconditionally refused because this yq invocation was run with file access disabled.

Source

Thrown at pkg/yqlib/operator_load.go:67

	if documents.Len() == 0 {
		// return null candidate
		return &CandidateNode{Kind: ScalarNode, Tag: "!!null"}, nil
	} else if documents.Len() == 1 {
		candidate := documents.Front().Value.(*CandidateNode)
		return candidate, nil

	}
	sequenceNode := &CandidateNode{Kind: SequenceNode}
	for doc := documents.Front(); doc != nil; doc = doc.Next() {
		sequenceNode.AddChild(doc.Value.(*CandidateNode))
	}
	return sequenceNode, nil
}

func loadStringOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
	log.Debugf("loadString")
	if ConfiguredSecurityPreferences.DisableFileOps {
		return Context{}, fmt.Errorf("file operations have been disabled")
	}

	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

View on GitHub (pinned to 8b5af0694b)

Solutions

  1. Re-run yq without the security flag that disables file ops
  2. Read the file externally (cat file | yq ...) and drop the load/loadString call
  3. Only use load in trusted contexts where file operations are permitted
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/yqlib/operator_load.go:67 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/ef561a1fce4321ea. Report an issue: GitHub.