Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-6276

MongoWriteConcernError overwrites top-level code in constructor

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.9.0
    • Affects Version/s: None
    • Component/s: None
    • 3
    • Not Needed
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Description

      1. 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.
      2.  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`

            Assignee:
            aditi.khare@mongodb.com Aditi Khare
            Reporter:
            aditi.khare@mongodb.com Aditi Khare
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: