Skip to content

Fix update(updates:) reporting success as failure when the server ID isn't 1 - #31

Merged
taplin merged 1 commit into
mainfrom
fix-bulk-update-execute
Sep 29, 2026
Merged

taplin merged 1 commit into
mainfrom
fix-bulk-update-execute

Conversation

@taplin

@taplin taplin commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Brings the fix from #28 (by @sportlabsMike) forward to 4.x, where the bug is still present.

mongoc_bulk_operation_execute returns the ID of the server that ran the write, or 0 on failure. MongoCollection.update(updates:) compared the result to 1, so a successful bulk update returned .error whenever the server's ID wasn't 1. Against a single local mongod the ID is always 1, which is why the tests never caught it; replica sets and Atlas commonly use other IDs. The fix checks for non-zero, as insert(documents:) already does.

The full suite (36 tests) passes locally. There's no regression test, because reproducing it needs a server ID other than 1, meaning a replica-set member.

After merging, this is a candidate for a 4.0.1 patch release.

🤖 Generated with Claude Code

mongoc_bulk_operation_execute returns the ID of the server that ran the
write, or 0 on failure. update(updates:) compared the result to 1, so a
successful bulk update reported an error whenever the server's ID wasn't
1, as is common on replica sets and Atlas. Check for non-zero, as
insert(documents:) already does. Originally reported and fixed in #28.

Co-Authored-By: Mike Pollard <mike.pollard@clubspark.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@taplin
taplin merged commit 6b8fe03 into main Sep 29, 2026
4 checks passed
@taplin
taplin deleted the fix-bulk-update-execute branch September 29, 2026 14:39
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.

1 participant