{"record":{"id":"6d5bbcef384fe84a","repo":"Automattic/mongoose","slug":"must-specify-operation-name-in-connection-prototyp","errorCode":null,"errorMessage":"Must specify operation name in Connection.prototype.bulkWrite()","messagePattern":"Must specify operation name in Connection\\.prototype\\.bulkWrite\\(\\)","errorType":"validation","errorClass":"MongooseError","httpStatus":null,"severity":"error","filePath":"lib/connection.js","lineNumber":478,"sourceCode":"  const ordered = options.ordered == null ? true : options.ordered;\n  const asyncLocalStorage = this.base.transactionAsyncLocalStorage?.getStore();\n  if ((!options || !Object.hasOwn(options, 'session')) && asyncLocalStorage?.session != null) {\n    options = { ...options, session: asyncLocalStorage.session };\n  }\n\n  const now = this.base.now();\n\n  let res = null;\n  if (ordered) {\n    const opsToSend = [];\n    for (const op of ops) {\n      if (typeof op.model !== 'string' && !op.model?.[modelSymbol]) {\n        throw new MongooseError('Must specify model in Connection.prototype.bulkWrite() operations');\n      }\n      const Model = op.model[modelSymbol] ? op.model : this.model(op.model);\n\n      if (op.name == null) {\n        throw new MongooseError('Must specify operation name in Connection.prototype.bulkWrite()');\n      }\n      if (!Object.hasOwn(castBulkWrite.cast, op.name)) {\n        throw new MongooseError(`Unrecognized bulkWrite() operation name ${op.name}`);\n      }\n\n      await castBulkWrite.cast[op.name](Model, op, options, now);\n      opsToSend.push({ ...op, namespace: Model.namespace() });\n    }\n\n    res = await this.client.bulkWrite(opsToSend, options);\n  } else {\n    const validOps = [];\n    const validOpIndexes = [];\n    let validationErrors = [];\n    const asyncValidations = [];\n    const results = [];\n    for (let i = 0; i < ops.length; ++i) {\n      const op = ops[i];","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/connection.js#L460-L496","documentation":"Error \"Must specify operation name in Connection.prototype.bulkWrite()\" thrown in Automattic/mongoose.","triggerScenarios":"Thrown at lib/connection.js:478 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":"49cdab01366679723b487ecb754b38570f783289","analyzedAt":"2026-08-21T22:54:00.882Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}