{"record":{"id":"fc0cb4651c29e438","repo":"mongodb/mongoid","slug":"resolved-path-is-nil-on-this-document-cannot-p-fc0cb4","errorCode":null,"errorMessage":"#{resolved_path} is nil on this document; cannot perform auto-embed search","messagePattern":"#(.+?) is nil on this document; cannot perform auto-embed search","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/mongoid/search_indexable.rb","lineNumber":133,"sourceCode":"    #   to use (optional when only one is declared on the model).\n    # @param [ String | Symbol | nil ] path The indexed text field path\n    #   (optional if unambiguous from the index definition).\n    # @param [ Integer ] limit Maximum number of results (default: 10).\n    # @param [ Integer | nil ] num_candidates Candidates for ANN search;\n    #   defaults to limit * 10. Ignored when exact: true.\n    # @param [ Hash | nil ] filter Optional MongoDB filter for pre-filtering.\n    # @param [ true | false ] exact Use exact nearest-neighbor search (default: false).\n    # @param [ String | nil ] model Query-time embedding model override.\n    # @param [ Array ] pipeline Additional aggregation stages to append.\n    #\n    # @return [ Array<Mongoid::Document> ] matching documents, each with\n    #   a populated +vector_search_score+ attribute.\n    def auto_embed_search(index: nil, path: nil, limit: 10, num_candidates: nil, filter: nil, exact: false, model: nil, pipeline: []) # rubocop:disable Metrics/ParameterLists\n      _index, resolved_path = self.class.send(:resolve_auto_embed_index, index, path)\n      text = public_send(resolved_path)\n\n      if text.nil?\n        raise ArgumentError,\n              \"#{resolved_path} is nil on this document; cannot perform auto-embed search\"\n      end\n\n      self_exclusion = { '$match' => { '_id' => { '$ne' => _id } } }\n      post_pipeline = [ self_exclusion, { '$limit' => limit }, *Array(pipeline) ]\n      effective_candidates = num_candidates || (limit * 10)\n\n      self.class.auto_embed_search(\n        text,\n        index: index,\n        path: path,\n        limit: limit + 1,\n        num_candidates: effective_candidates,\n        filter: filter,\n        exact: exact,\n        model: model,\n        pipeline: post_pipeline\n      )","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/search_indexable.rb#L115-L151","documentation":"Error \"#{resolved_path} is nil on this document; cannot perform auto-embed search\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/search_indexable.rb:133 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}