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

feat(NODE-5988): Provide access to raw results doc after MongoServerError #4016

Merged
merged 7 commits into from
Mar 7, 2024

Conversation

aditi-khare-mongoDB
Copy link
Contributor

@aditi-khare-mongoDB aditi-khare-mongoDB commented Mar 4, 2024

Description

Provide access to raw results doc in MongoServerError.

What is changing?

See release highlight.

Is there new documentation needed for these changes?

Yes, API docs.

What is the motivation for this change?

Provide support for all values returned by server error.

Release Highlight

Add property errorResponse to MongoServerError

The MongoServerError.errorResponse property now contains the raw error document returned by the server.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@aditi-khare-mongoDB aditi-khare-mongoDB marked this pull request as ready for review March 6, 2024 21:32
@baileympearson baileympearson self-assigned this Mar 7, 2024
@baileympearson baileympearson self-requested a review March 7, 2024 15:10
Copy link
Contributor

@baileympearson baileympearson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two small comments, otherwise looks good. Nice work!

@@ -425,6 +425,10 @@ describe('CRUD spec v1', function () {
}
});

// The Node driver does not have a Collection.modifyCollection helper.
const SKIPPED_TESTS = ['findOneAndUpdate document validation errInfo is accessible'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are different from the collection management specs. These tests use the modifyCollection operation to set up the collection for the test, but they're not testing the driver's modifyCollection helper.

I think it might make sense to implement a unified test format helper for modifyCollection that uses runCommandto send a collMod to the server (i.e., a new operation in operations.ts). Then we could unskip this test. We'd still leave the modifyCollection tests alone though because we don't have a driver helper.

what do you think?

(also see https://github.com/mongodb/specifications/pull/1316/files#r994171436)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could merge these changes and make a separate subtask or even ticket for adding in the modifyCollection changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me - if we file a separate ticket, can we add a TODO(NODE-XXXX) comment here so we don't forget about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! Just filed the ticket NODE-5998.

src/error.ts Outdated
@@ -200,6 +200,8 @@ export class MongoError extends Error {
* @category Error
*/
export class MongoServerError extends MongoError {
/** Raw error result document returned by server. */
errorResponse?: ErrorDescription;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be required? We always assign it in the constructor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally it should be. There were some type errors since we feed MongoError instances into MongoServerError fields in parts of the driver, so I just casted these instances as MongoServerError as a fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you file a subtask to fix the type errors this uncovered (tackling it as follow-up is fine since it's a separate issue)? I think it's a bug in the driver's types but we'll need to look to be sure - ideally we'd fix the type issue instead of just casting it away.

We have a number of instances of MongoServerError that are actually invoked with MongoErrors, which worked before because MongoError was assignable to MongoServerError.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, here's the link to the ticket.

@aditi-khare-mongoDB aditi-khare-mongoDB force-pushed the NODE-5988/6.x-raw-results-doc-MongoServerError branch from 21d90ad to 2b2f64c Compare March 7, 2024 18:52
@baileympearson baileympearson merged commit c023242 into main Mar 7, 2024
4 of 7 checks passed
@baileympearson baileympearson deleted the NODE-5988/6.x-raw-results-doc-MongoServerError branch March 7, 2024 20:59
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.

2 participants