Skip to content

Commit

Permalink
DRIVERS-2865: Require drivers to always send out bypassDocumentValida…
Browse files Browse the repository at this point in the history
…tion (#1703)
  • Loading branch information
alcaeus authored Nov 4, 2024
1 parent 38cbbce commit b1b5a7f
Show file tree
Hide file tree
Showing 4 changed files with 724 additions and 20 deletions.
13 changes: 0 additions & 13 deletions source/crud/bulk-write.md
Original file line number Diff line number Diff line change
Expand Up @@ -897,19 +897,6 @@ recording the summary counts. We expect that most users are not interested in th
and that most users will rely on defaults, so `verboseResults` defaults to `false` to improve performance in the common
case.

### Why should drivers send `bypassDocumentValidation: false` for `bulkWrite`?

[DRIVERS-450](https://jira.mongodb.org/browse/DRIVERS-450) introduced a requirement that drivers only send a value for
`bypassDocumentValidation` on write commands if it was specified as true. The original motivation for this change is not
documented. This specification requires that drivers send `bypassDocumentValidation` in the `bulkWrite` command if it is
set by the user in `BulkWriteOptions`, regardless of its value.

Explicitly defining `bypassDocumentValidation: false` aligns with the server's default to perform schema validation and
thus has no effect. However, checking the value of an option that the user specified and omitting it from the command
document if it matches the server's default creates unnecessary work for drivers. Always sending the user's specified
value also safeguards against the unlikely event that the server changes the default value for
`bypassDocumentValidation` in the future.

### Why is providing access to the raw server response when a command error occurs required?

This allows users to access new error fields that the server may add in the future without needing to upgrade their
Expand Down
16 changes: 9 additions & 7 deletions source/crud/crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ class BulkWriteOptions {
/**
* If true, allows the write to opt-out of document level validation.
*
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
* For unacknowledged writes using OP_INSERT, OP_UPDATE, or OP_DELETE, the driver MUST raise an error if the caller explicitly provides a value.
*/
Expand Down Expand Up @@ -959,7 +959,7 @@ class InsertOneOptions {
/**
* If true, allows the write to opt-out of document level validation.
*
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
* For unacknowledged writes using OP_INSERT, the driver MUST raise an error if the caller explicitly provides a value.
*/
Expand All @@ -981,7 +981,7 @@ class InsertManyOptions {
/**
* If true, allows the write to opt-out of document level validation.
*
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
* For unacknowledged writes using OP_INSERT, the driver MUST raise an error if the caller explicitly provides a value.
*/
Expand Down Expand Up @@ -1021,7 +1021,7 @@ class UpdateOptions {
/**
* If true, allows the write to opt-out of document level validation.
*
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
* For unacknowledged writes using OP_UPDATE, the driver MUST raise an error if the caller explicitly provides a value.
*/
Expand Down Expand Up @@ -1101,7 +1101,7 @@ class ReplaceOptions {
/**
* If true, allows the write to opt-out of document level validation.
*
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
* For unacknowledged writes using OP_UPDATE, the driver MUST raise an error if the caller explicitly provides a value.
*/
Expand Down Expand Up @@ -1983,7 +1983,7 @@ class FindOneAndReplaceOptions {
/**
* If true, allows the write to opt-out of document level validation.
*
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
*/
bypassDocumentValidation: Optional<Boolean>;
Expand Down Expand Up @@ -2101,7 +2101,7 @@ class FindOneAndUpdateOptions {
/**
* If true, allows the write to opt-out of document level validation.
*
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
*/
bypassDocumentValidation: Optional<Boolean>;
Expand Down Expand Up @@ -2486,6 +2486,8 @@ aforementioned allowance in the SemVer spec.
## Changelog
- 2024-11-04: Always send a value for `bypassDocumentValidation` if it was specified.
- 2024-10-30: Document query limitations in `countDocuments`.
- 2024-10-28: Clarified that generated identifiers should be prepended to documents.
Expand Down
Loading

0 comments on commit b1b5a7f

Please sign in to comment.