Details
-
Bug
-
Resolution: Unresolved
-
Major - P3
-
None
-
None
-
Server Tooling & Methods
-
ALL
-
Repl 2019-02-11
Description
Try this:
try {
|
assert.commandWorked({
|
"n" : 0,
|
"writeErrors" : [
|
{
|
"index" : 0,
|
"code" : 263,
|
"errmsg" : "foo"
|
}
|
],
|
"ok" : 1
|
});
|
} catch (ex) {
|
print(typeof ex.code);
|
}
|
Expected: number
Actual: object
The problem is _getErrorWithCode(), compiled into the shell from utils.js. That function expects the provided error object to be a command failure with ok: 0, or an object with a "writeError" field, not a "writeErrors" array.
I think _getErrorWithCode() should check for writeErrors, too. I'm not sure "writeError" is ever actually present.
This is a problem for tests that check things like "ex.code === 123". If the command failed with a writeErrors array, the exception's code is an object, not the expected number, and the check may be false incorrectly.
Attachments
Issue Links
- is related to
-
SERVER-38583 Transactional bulkWrite error missing writeErrors (mongod)
-
- Closed
-
- related to
-
SERVER-38936 Create unittests for txn_override.js
-
- Closed
-