-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
Description
- The `MongoWriteConcernError` constructor currently overwrites the top-level error code (MongoWriteConcernError.code) with the nested (MongoWriteConcernError.writeConcernError). If there was originally no top-level code, then the nested writeConcernError's code will be set as the top-level code.
- When determining whether or not to add `retryableWriteLabel`, `MongoWriteConcernError's` result property is incorrectly accessed (it should be `MongoWriteConcernError.result.writeConcernError.code`)
Unknowns
- How do the changes in this commit affect the behavior of MongoWriteConcernError?
Acceptance Criteria
Implementation Requirements
- Ensure that MongoWriteConcernError is correctly formed such that the original top-level code is preserved
- If no top-level code exists, MongoWriteConcernError.code should be set to the nested code
- If a top-level code is passed into the constructor, it shouldn't be changed or overwritten by the nested writeConcernError.code
- Add stricter typing for MongoWriteConcernError properties so that nested properties are not improperly accessed
Testing Requirements
- All existing tests pass
- Add unit test explicitly asserting that top-level `error.code` is not overwritten by nested `error.writeConcernError.code`