[SERVER-44673] assert.commandWorkedOrFailedWithCode() should support write errors Created: 15/Nov/19  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: James Wahlin Assignee: Backlog - Server Tooling and Methods (STM) (Inactive)
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Server Tooling & Methods
Operating System: ALL
Steps To Reproduce:

The following demonstrates this behavior:

(function() {
"use strict";
 
db.test.drop();
let cmdRes = db.runCommand({insert: "test", documents: [{_id: 1}]});
assert.commandWorked(cmdRes);
 
// Will result in a duplicateKey error.
cmdRes = db.runCommand({insert: "test", documents: [{_id: 1}]});
 
assert.commandFailed(cmdRes);
assert.commandFailedWithCode(cmdRes, ErrorCodes.DuplicateKey);
 
// While the above assertions pass, this one fails.
assert.commandWorkedOrFailedWithCode(cmdRes, ErrorCodes.DuplicateKey);
})();

Participants:

 Description   

assert.commandWorkedOrFailedWithCode() calls assert.commandWorked() if a command result has "ok : 1" field or assert.commandFailedWithCode() if not.

In the case of a write error, where the response has both "ok: 1" and one or more errors reported in a "writeErrors" subdocument, assert.commandWorked() will be called which then asserts when the write error is encountered, regardless of whether the code is in the set passed to assert.commandWorkedOrFailedWithCode().



 Comments   
Comment by Steven Vannelli [ 10/May/22 ]

Moving this ticket to the Backlog and removing the "Backlog" fixVersion as per our latest policy for using fixVersions.

Comment by Ian Whalen (Inactive) [ 13/Jan/20 ]

Backlogging this although anyone else is welcome to pick this up - we're unlikely to pick this up ourselves anytime soon.

Generated at Thu Feb 08 05:06:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.