@@ -866,7 +866,7 @@ class MongoClientInterface {
866866 c . bulkWrite ( ops , {
867867 ordered : true ,
868868 } )
869- . then ( ( ) => cb ( null , `{"versionId": " ${ versionId } " }` ) )
869+ . then ( ( ) => cb ( null , `{"versionId": ${ JSON . stringify ( versionId ) } }` ) )
870870 . catch ( ( err : MongoBulkWriteError ) => {
871871 /*
872872 * Previously related to https://jira.mongodb.org/browse/SERVER-14322
@@ -902,7 +902,7 @@ class MongoClientInterface {
902902 // This error is expected, it means that two differents version were
903903 // put at the same time.
904904 if ( isMasterOpError ) {
905- return cb ( null , `{"versionId": " ${ versionId } " }` ) ;
905+ return cb ( null , `{"versionId": ${ JSON . stringify ( versionId ) } }` ) ;
906906 }
907907
908908 // If no upserts succeeded and this is not a retry yet, try again with a new version ID
@@ -958,7 +958,7 @@ class MongoClientInterface {
958958 { $set : { value : objVal } , $setOnInsert : { _id : masterKey } } ,
959959 { upsert : true } ,
960960 )
961- . then ( ( ) => cb ( null , `{"versionId": " ${ objVal . versionId } " }` ) )
961+ . then ( ( ) => cb ( null , `{"versionId": ${ JSON . stringify ( objVal . versionId ) } }` ) )
962962 . catch ( ( err ) => {
963963 log . error ( 'putObjectVerCase2: error putting object version' , { error : err . message } ) ;
964964 return cb ( errors . InternalError ) ;
@@ -1003,7 +1003,7 @@ class MongoClientInterface {
10031003 c . bulkWrite ( ops , {
10041004 ordered : true ,
10051005 } )
1006- . then ( ( ) => callback ( null , `{"versionId": " ${ objVal . versionId } " }` ) )
1006+ . then ( ( ) => callback ( null , `{"versionId": ${ JSON . stringify ( objVal . versionId ) } }` ) )
10071007 . catch ( err => {
10081008 log . error ( 'putObjectVerCase3: error putting object version' , { error : err . message } ) ;
10091009 if ( err . code === 11000 ) {
@@ -1158,12 +1158,12 @@ class MongoClientInterface {
11581158 ops . push ( masterOp ) ;
11591159 return c . bulkWrite ( ops , {
11601160 ordered : true ,
1161- } ) . then ( ( ) => cb ( null , `{"versionId": " ${ objVal . versionId } " }` ) ) . catch ( ( err ) => {
1161+ } ) . then ( ( ) => cb ( null , `{"versionId": ${ JSON . stringify ( objVal . versionId ) } }` ) ) . catch ( ( err ) => {
11621162 // we accept that the update fails if
11631163 // condition is not met, meaning that a more
11641164 // recent master was already in place
11651165 if ( err . code === 11000 ) {
1166- return cb ( null , `{"versionId": " ${ objVal . versionId } " }` ) ;
1166+ return cb ( null , `{"versionId": ${ JSON . stringify ( objVal . versionId ) } }` ) ;
11671167 }
11681168 log . error ( 'putObjectVerCase4: error upserting master' , { error : err . message } ) ;
11691169 return cb ( errors . InternalError ) ;
0 commit comments