File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
src/Adapters/Storage/Mongo Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -3842,6 +3842,7 @@ describe('schemas', () => {
38423842 } ) ;
38433843
38443844 it_id ( 'cbd5d897-b938-43a4-8f5a-5d02dd2be9be' ) ( it_exclude_dbs ( [ 'postgres' ] ) ) ( 'cannot update to duplicate value on unique index' , done => {
3845+ loggerErrorSpy . calls . reset ( ) ;
38453846 const index = {
38463847 code : 1 ,
38473848 } ;
@@ -3868,6 +3869,12 @@ describe('schemas', () => {
38683869 . then ( done . fail )
38693870 . catch ( error => {
38703871 expect ( error . code ) . toEqual ( Parse . Error . DUPLICATE_VALUE ) ;
3872+ // Client should only see generic message (no schema info exposed)
3873+ expect ( error . message ) . toEqual ( 'A duplicate value for a field with unique values was provided' ) ;
3874+ // Server logs should contain full MongoDB error message with detailed information
3875+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Duplicate key error:' , jasmine . stringContaining ( 'E11000 duplicate key error' ) ) ;
3876+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Duplicate key error:' , jasmine . stringContaining ( 'test_UniqueIndexClass' ) ) ;
3877+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Duplicate key error:' , jasmine . stringContaining ( 'code_1' ) ) ;
38713878 done ( ) ;
38723879 } ) ;
38733880 } ) ;
Original file line number Diff line number Diff line change @@ -519,7 +519,7 @@ export class MongoStorageAdapter implements StorageAdapter {
519519 . then ( ( ) => ( { ops : [ mongoObject ] } ) )
520520 . catch ( error => {
521521 if ( error . code === 11000 ) {
522- // Duplicate value
522+ logger . error ( ' Duplicate key error:' , error . message ) ;
523523 const err = new Parse . Error (
524524 Parse . Error . DUPLICATE_VALUE ,
525525 'A duplicate value for a field with unique values was provided'
@@ -605,6 +605,7 @@ export class MongoStorageAdapter implements StorageAdapter {
605605 . then ( result => mongoObjectToParseObject ( className , result , schema ) )
606606 . catch ( error => {
607607 if ( error . code === 11000 ) {
608+ logger . error ( 'Duplicate key error:' , error . message ) ;
608609 throw new Parse . Error (
609610 Parse . Error . DUPLICATE_VALUE ,
610611 'A duplicate value for a field with unique values was provided'
You can’t perform that action at this time.
0 commit comments