{"record":{"id":"7abb2194c86eef91","repo":"mikefarah/yq","slug":"filename-expression-returned-nil","errorCode":null,"errorMessage":"filename expression returned nil","messagePattern":"filename expression returned nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/yqlib/operator_load.go","lineNumber":80,"sourceCode":"}\n\nfunc loadStringOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {\n\tlog.Debugf(\"loadString\")\n\tif ConfiguredSecurityPreferences.DisableFileOps {\n\t\treturn Context{}, fmt.Errorf(\"file operations have been disabled\")\n\t}\n\n\tvar results = list.New()\n\n\tfor el := context.MatchingNodes.Front(); el != nil; el = el.Next() {\n\t\tcandidate := el.Value.(*CandidateNode)\n\n\t\trhs, err := d.GetMatchingNodes(context.SingleReadonlyChildContext(candidate), expressionNode.RHS)\n\t\tif err != nil {\n\t\t\treturn Context{}, err\n\t\t}\n\t\tif rhs.MatchingNodes.Front() == nil {\n\t\t\treturn Context{}, fmt.Errorf(\"filename expression returned nil\")\n\t\t}\n\t\tnameCandidateNode := rhs.MatchingNodes.Front().Value.(*CandidateNode)\n\n\t\tfilename := nameCandidateNode.Value\n\n\t\tcontentsCandidate, err := loadString(filename)\n\t\tif err != nil {\n\t\t\treturn Context{}, fmt.Errorf(\"failed to load %v: %w\", filename, err)\n\t\t}\n\n\t\tresults.PushBack(contentsCandidate)\n\n\t}\n\n\treturn context.ChildContext(results), nil\n}\n\nfunc loadOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/mikefarah/yq/blob/8b5af0694bb82b41d4ae180fac9972029066f90a/pkg/yqlib/operator_load.go#L62-L98","documentation":"loadString evaluates its RHS expression to obtain a filename; the evaluation succeeded but produced zero matching nodes (front() == nil). There is no filename to open — typically the filename expression selected a missing field or filtered everything out.","triggerScenarios":"Thrown at pkg/yqlib/operator_load.go:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the filename expression always yield a string, e.g. \"file.yaml\" as a literal","Check that the field holding the filename exists: .filename // \"default.yaml\"","Avoid select() filters that can return nothing on the RHS of load"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8b5af0694bb82b41d4ae180fac9972029066f90a","analyzedAt":"2026-09-05T10:57:22.766Z","contentChangedAt":"2026-09-05T10:57:22.766Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}