[SERVER-11634] Write command authentication returning wrong fields on error Created: 08/Nov/13  Updated: 10/Dec/14  Resolved: 18/Nov/13

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

Type: Bug Priority: Major - P3
Reporter: Christian Amor Kvalheim Assignee: Greg Studer
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Operating System: ALL
Steps To Reproduce:

//
// Ensures that mongod respects the batch write protocols
//
var request;
var result;
 
print("START batch_write_command_auth.js");
 
var port = allocatePorts(1)[0];
var dbName = "batch_write_protocol_auth";
 
var mongoInstance = startMongod( "--auth", "--port", port, "--dbpath", "/data/db/" + dbName, "--nohttpinterface", "--bind_ip", "127.0.0.1" );
var db = mongoInstance.getDB("test");
 
// Get the collection name
var collectionName = "batch_write_protocol";
var coll = db.getCollection(collectionName);
 
// Get the test db we are running against and make sure it's gone
var testDb = db[dbName];
testDb.drop();
 
// Drop all users on the db
db.dropAllUsers();
 
// Add an admin user
db.getSisterDB( "admin" ).addUser({user: "super", pwd: "super", roles: ["__system"] });
db.getSisterDB("admin").auth("super", "super");
// Add a standard user
db.addUser({user: "guest" , pwd: "guest", roles: jsTest.readOnlyUserRoles});
// Add a read only user
db.addUser({user: "eliot" , pwd: "eliot", roles: jsTest.basicUserRoles });
// Log out
db.getSisterDB("admin").logout();
 
/**
 * Attempt to execute write batches without any authentication performed
 */
 
//
// Single document insert, w:1 write concern specified, ordered:false
request = {insert : collectionName
	, documents: [{a:1}]
	, writeConcern:{w:1}
	, ordered:false};
result = coll.runCommand(request);
jsTest.log(JSON.stringify(result, null, 2))
assert.eq(0, result.ok);
assert.eq(13, result.errCode);
assert.eq('string', typeof result.errmsg);

Participants:

 Description   

When performing an unauthorized write command it returns the wrong fields



 Comments   
Comment by Greg Studer [ 18/Nov/13 ]

As of the latest spec, this is no longer the case - errCode -> code (in errDetails too) to standardize write commands with other commands' return values.

Comment by Christian Amor Kvalheim [ 08/Nov/13 ]

To clarify. Errors returned from the write commands look like this

{
    ok: 0
  , errCode: 11000
  , errmsg: "some error message"
}

Errors returned if an auth error happens looks like this

{
    ok: 0
  , errmsg: "some error message"
  , code: 13
}

so it's just a mismatch in field naming

Generated at Thu Feb 08 03:26:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.