{"id":"69fb5d3348057d0b","repo":"mongodb/node-mongodb-native","slug":"cannot-request-unacknowledged-write-concern-and-ve","errorCode":null,"errorMessage":"Cannot request unacknowledged write concern and verbose results","messagePattern":"Cannot request unacknowledged write concern and verbose results","errorType":"exception","errorClass":"MongoInvalidArgumentError","httpStatus":null,"severity":"error","filePath":"src/operations/client_bulk_write/executor.ts","lineNumber":64,"sourceCode":"    }\n\n    this.client = client;\n    this.operations = operations;\n    this.options = {\n      ordered: true,\n      bypassDocumentValidation: false,\n      verboseResults: false,\n      ...options\n    };\n\n    // If no write concern was provided, we inherit one from the client.\n    if (!this.options.writeConcern) {\n      this.options.writeConcern = WriteConcern.fromOptions(this.client.s.options);\n    }\n\n    if (this.options.writeConcern?.w === 0) {\n      if (this.options.verboseResults) {\n        throw new MongoInvalidArgumentError(\n          'Cannot request unacknowledged write concern and verbose results'\n        );\n      }\n\n      if (this.options.ordered) {\n        throw new MongoInvalidArgumentError(\n          'Cannot request unacknowledged write concern and ordered writes'\n        );\n      }\n    }\n  }\n\n  /**\n   * Execute the client bulk write. Will split commands into batches and exhaust the cursors\n   * for each, then merge the results into one.\n   * @returns The result.\n   */\n  async execute(): Promise<ClientBulkWriteResult> {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/operations/client_bulk_write/executor.ts#L46-L82","documentation":"Thrown by the ClientBulkWriteExecutor constructor when write concern w:0 (unacknowledged) is combined with verboseResults: true. Unacknowledged writes receive no per-document results, so requesting verbose results is contradictory. MongoInvalidArgumentError fires before execution.","triggerScenarios":"Calling client.bulkWrite(models, { writeConcern: { w: 0 }, verboseResults: true }); also when a client-level w:0 write concern is inherited and verboseResults is enabled.","commonSituations":"Enabling verboseResults for debugging while the client/connection string sets w:0 for throughput; inheriting an unacknowledged write concern from the client and turning on verbose results.","solutions":["Drop verboseResults when using w:0, since no per-doc results are returned.","Use an acknowledged write concern (w:1 or majority) if you need verbose per-document results.","Resolve the effective write concern: if client.s.options has w:0, do not pass verboseResults."],"exampleFix":"// before\nawait client.bulkWrite(models, {\n  writeConcern: { w: 0 },\n  verboseResults: true // throws\n});\n\n// after\nawait client.bulkWrite(models, {\n  writeConcern: { w: 0 }\n});","handlingStrategy":"validation","validationCode":"if (options.writeConcern?.w === 0) options.verboseResults = false;","typeGuard":"function isUnacknowledged(wc): boolean { return wc?.w === 0; }","tryCatchPattern":null,"preventionTips":["Never combine w:0 with verboseResults","Resolve effective write concern before setting verbose options","Remember w:0 yields no per-document results"],"tags":["bulk-write","write-concern","client-bulk-write","options-conflict"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}