-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(NODE-5988): Provide access to raw results doc after MongoServerError #4016
Conversation
There was a problem hiding this 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']; |
There was a problem hiding this comment.
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 runCommand
to 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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 MongoError
s, which worked before because MongoError
was assignable to MongoServerError
.
There was a problem hiding this comment.
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.
21d90ad
to
2b2f64c
Compare
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
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript