{"record":{"id":"e571e8c1b340be00","repo":"mongodb/mongoid","slug":"cannot-create-collection-collection-name-with-o","errorCode":null,"errorMessage":"Cannot create collection %{collection_name} with options %{collection_options}. The following error was raised: %{error}.","messagePattern":"Cannot create collection %(.+?) with options %(.+?)\\. The following error was raised: %(.+?)\\.","errorType":"exception","errorClass":"Mongoid::Errors::CreateCollectionFailure","httpStatus":null,"severity":"error","filePath":"lib/mongoid/collection_configurable.rb","lineNumber":45,"sourceCode":"        if /^system\\./.match?(collection_name)\n          # We do not do anything with system collections.\n          return\n        end\n\n        collection.drop if force\n        if coll_options = collection.database.list_collections(filter: { name: collection_name.to_s }).first\n          raise Errors::DropCollectionFailure.new(collection_name) if force\n\n          logger.debug(\n            \"MONGOID: Collection '#{collection_name}' already exists \" +\n            \"in database '#{database_name}' with options '#{coll_options}'.\"\n          )\n\n        else\n          begin\n            collection.database[collection_name, storage_options.fetch(:collection_options, {})].create\n          rescue Mongo::Error::OperationFailure => e\n            raise Errors::CreateCollectionFailure.new(\n              collection_name,\n              storage_options[:collection_options],\n              e\n            )\n          end\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":27,"sourceCodeEnd":56,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/collection_configurable.rb#L27-L56","documentation":"Error \"Cannot create collection %{collection_name} with options %{collection_options}. The following error was raised: %{error}.\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/collection_configurable.rb:45 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"}