Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSHARP-5449: Retry does not work with BulkWrite operations within the session #1598

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/MongoDB.Driver/ClientBulkWriteException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ public ClientBulkWriteException(
WriteErrors = writeErrors;
PartialResult = partialResult;
WriteConcernErrors = writeConcernErrors;

if (innerException is MongoException innerMongoException)
{
foreach (var errorLabel in innerMongoException.ErrorLabels)
{
AddErrorLabel(errorLabel);
}
}

if (writeConcernErrors != null)
{
foreach (var writeConcernError in writeConcernErrors)
{
foreach (var errorLabel in writeConcernError.ErrorLabels)
{
AddErrorLabel(errorLabel);
}
}
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ private void AssertErrorContains(Exception actualException, string expectedSubst

private void AssertErrorLabelsContain(Exception actualException, IEnumerable<string> expectedErrorLabels)
{
if (actualException is ClientBulkWriteException bulkWriteException)
{
actualException = bulkWriteException.InnerException;
}

var mongoException = actualException.Should().BeAssignableTo<MongoException>().Subject;
mongoException.ErrorLabels.Should().Contain(expectedErrorLabels);
}
Expand Down