{"record":{"id":"510503e9c73b4fae","repo":"mongodb/mongoid","slug":"no-auto-embed-index-index-declared-on-name","errorCode":null,"errorMessage":"No auto-embed index '#{index}' declared on #{name}","messagePattern":"No auto-embed index '#(.+?)' declared on #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/mongoid/search_indexable.rb","lineNumber":502,"sourceCode":"\n        # Extracted to keep cyclomatic complexity within RuboCop's threshold.\n        spec = select_auto_embed_spec(auto_embed_specs, index)\n        resolved_index = spec[:name] || 'default'\n        resolved_path  = path ? path.to_s : infer_auto_embed_path(spec)\n\n        [ resolved_index, resolved_path ]\n      end\n\n      # Picks one spec from the list of auto-embed specs, guided by +index+.\n      #\n      # @param [ Array<Hash> ] specs The candidate auto-embed specs.\n      # @param [ String | Symbol | nil ] index The requested index name.\n      #\n      # @return [ Hash ] the selected spec.\n      def select_auto_embed_spec(specs, index)\n        if index\n          found = specs.find { |s| s[:name] == index.to_s }\n          raise ArgumentError, \"No auto-embed index '#{index}' declared on #{name}\" unless found\n\n          found\n        elsif specs.size == 1\n          specs.first\n        else\n          raise ArgumentError,\n                \"#{name} has multiple auto-embed indexes; specify index: to select one\"\n        end\n      end\n\n      # Infers the text field path from an index definition by locating\n      # the first field declared with type 'autoEmbed'.\n      #\n      # @param [ Hash ] spec The vector search index spec.\n      #\n      # @return [ String ] the field path.\n      def infer_auto_embed_path(spec)\n        field_list = spec.dig(:definition, :fields) || spec.dig(:definition, 'fields') || []","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/search_indexable.rb#L484-L520","documentation":"Error \"No auto-embed index '#{index}' declared on #{name}\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/search_indexable.rb:502 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"}