Skip to content

DRIVERS-3684 Mandate reporting write concern errors - #1998

Merged
isabelatkinson merged 9 commits into
mongodb:masterfrom
isabelatkinson:wce
Oct 27, 2026
Merged

isabelatkinson merged 9 commits into
mongodb:masterfrom
isabelatkinson:wce

Conversation

@isabelatkinson

Copy link
Copy Markdown
Contributor

Please complete the following before merging:

  • Is the relevant DRIVERS ticket in the PR title?
  • Update changelog.
  • Test changes in at least one language driver.
  • Test these changes against all server versions and topologies (including standalone, replica set, and sharded
    clusters).

Rust implementation: mongodb/mongo-rust-driver#1840

Comment on lines +39 to +40
expectError:
isError: true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the unified test runner spec doesn't currently support asserting on error codes for bulk errors. The purpose of these tests is to ensure that drivers aren't swallowing write concern errors, so it should be sufficient in these cases just to assert that an error was returned.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Missing data isolation in both bulk-write fixtures allows duplicate-key errors to mask failures to report write concern errors.

1 open issue
What changed in this PR

This PR strengthens the MongoDB driver specification by requiring write concern errors to be reported and adding cross-driver tests for that behavior.

Changes:

  • Changes write concern error reporting from SHOULD to MUST for methods accepting a WriteConcern.
  • Adds failpoint-based unified tests and generated JSON across write-capable operations.
  • Documents the new test suite and updates the specification changelog.
File Description
source/​read-write-concern/​tests/​write-concern-errors/​mapReduce.yml Tests error reporting for mapReduce output writes.
source/​read-write-concern/​tests/​write-concern-errors/​mapReduce.json Generated mapReduce test.
source/​read-write-concern/​tests/​write-concern-errors/​index-management.yml Tests index creation and deletion errors.
source/​read-write-concern/​tests/​write-concern-errors/​index-management.json Generated index-management tests.
source/​read-write-concern/​tests/​write-concern-errors/​gridfs.yml Tests chunk and file-document upload errors.
source/​read-write-concern/​tests/​write-concern-errors/​gridfs.json Generated GridFS tests.
source/​read-write-concern/​tests/​write-concern-errors/​findAndModify.yml Tests find-and-modify operation errors.
source/​read-write-concern/​tests/​write-concern-errors/​findAndModify.json Generated find-and-modify tests.
source/​read-write-concern/​tests/​write-concern-errors/​db-coll-management.yml Tests database and collection management errors.
source/​read-write-concern/​tests/​write-concern-errors/​db-coll-management.json Generated database and collection tests.
source/​read-write-concern/​tests/​write-concern-errors/​crud.yml Tests insert, update, replace, and delete errors.
source/​read-write-concern/​tests/​write-concern-errors/​crud.json Generated CRUD tests.
source/​read-write-concern/​tests/​write-concern-errors/​client-side-encryption.yml Tests data-key rewrapping errors.
source/​read-write-concern/​tests/​write-concern-errors/​client-side-encryption.json Generated encryption test.
source/​read-write-concern/​tests/​write-concern-errors/​client-bulkWrite.yml Tests client bulk-write errors on MongoDB 8.0+.
source/​read-write-concern/​tests/​write-concern-errors/​client-bulkWrite.json Generated client bulk-write test.
source/​read-write-concern/​tests/​write-concern-errors/​bulkWrite.yml Tests collection bulk-write errors.
source/​read-write-concern/​tests/​write-concern-errors/​bulkWrite.json Generated collection bulk-write test.
source/​read-write-concern/​tests/​write-concern-errors/​aggregate.yml Tests aggregation errors with $out and $merge.
source/​read-write-concern/​tests/​write-concern-errors/​aggregate.json Generated aggregation tests.
source/​read-write-concern/​tests/​README.md Describes the write concern error suite.
source/​read-write-concern/​read-write-concern.md Mandates reporting and updates test requirements and changelog.

Review effort: Balanced

@isabelatkinson
isabelatkinson marked this pull request as ready for review October 23, 2026 15:46
@isabelatkinson
isabelatkinson requested a review from a team as a code owner October 23, 2026 15:46
@codeowners-service-app

Copy link
Copy Markdown

Assigned GromNaN for team dbx-spec-maintainers-crud because qingyang-hu is out of office.

@kevinAlbs kevinAlbs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A not-yet-well-reviewed C driver draft implementation passes these tests: mongodb/mongo-c-driver#2517

Most of my suggestions are test tweaks and coverage additions. I think the only substantial comment is a wording change to indicate writeConcernError must always be parsed, unless it is a generic runCommand API.

provider: local

tests:
- description: rewrapManyDataKey reports a writeConcernError

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest testing additional ClientEncryption operations that send write commands: createDataKey, deleteKey, addKeyAltName, and removeKeyAltName. These operations are already referenced in other unified tests, so I expect are already supported by test runners.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@kevinAlbs kevinAlbs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Latest tests pass in C driver implementation locally, and are running in Evergreen.

@BorisDog BorisDog left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests pass in .NET locally.

GromNaN added a commit to GromNaN/mongo-php-library that referenced this pull request Oct 27, 2026
Aggregate fell back to Server::executeCommand() whenever a read preference
was set. Collection always sets one, so a writeConcernError returned for a
pipeline ending in $out or $merge was never reported.

A primary read preference is the default for executeReadWriteCommand(), so
drop it and use that method, which reports the error.

Update the tests/specifications submodule to the DRIVERS-3684 branch
(mongodb/specifications#1998) and add the new write-concern-errors suite.
Skip it until the specifications PR is merged, since its failpoints omit
errmsg and the runner does not support dropIndexes, dropDatabase on a client
and mapReduce.
@isabelatkinson
isabelatkinson merged commit 775c4bc into mongodb:master Oct 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants