@@ -12320,6 +12320,113 @@ describe('ParseGraphQLServer', () => {
1232012320 }
1232112321 } ) ;
1232212322
12323+ it ( 'should sanitize non-Parse Error messages in createMany bulk when sanitization is enabled' , async ( ) => {
12324+ try {
12325+ await reconfigureGraphQLWithBatchLimit2AndOpenClient ( ) ;
12326+
12327+ Parse . Cloud . beforeSave ( 'BulkTest' , request => {
12328+ if ( request . object . get ( 'title' ) === 'FAIL' ) {
12329+ throw new Error ( 'internal stack detail' ) ;
12330+ }
12331+ } ) ;
12332+
12333+ await parseGraphQLServer . parseGraphQLSchema . schemaCache . clear ( ) ;
12334+
12335+ const { data } = await apolloClient . mutate ( {
12336+ mutation : gql `
12337+ mutation CreateManyBulkPlainErrorSanitized($input: CreateManyBulkTestInput!) {
12338+ createManyBulkTest(input: $input) {
12339+ results {
12340+ success
12341+ error {
12342+ code
12343+ message
12344+ }
12345+ bulkTest {
12346+ objectId
12347+ title
12348+ }
12349+ }
12350+ }
12351+ }
12352+ ` ,
12353+ variables : {
12354+ input : {
12355+ clientMutationId : uuidv4 ( ) ,
12356+ fields : [ { title : 'ok' } , { title : 'FAIL' } ] ,
12357+ } ,
12358+ } ,
12359+ context : {
12360+ headers : {
12361+ 'X-Parse-Master-Key' : 'test' ,
12362+ } ,
12363+ } ,
12364+ } ) ;
12365+
12366+ const [ ok , failed ] = data . createManyBulkTest . results ;
12367+ expect ( ok . success ) . toBe ( true ) ;
12368+ expect ( failed . success ) . toBe ( false ) ;
12369+ // Cloud Code wraps a plain Error as Parse.Error(SCRIPT_FAILED) before bulk handling;
12370+ // sanitized response matches other Parse.Error bulk failures.
12371+ expect ( failed . error . code ) . toBe ( Parse . Error . SCRIPT_FAILED ) ;
12372+ expect ( failed . error . message ) . toBe ( 'Permission denied' ) ;
12373+ } catch ( e ) {
12374+ handleError ( e ) ;
12375+ }
12376+ } ) ;
12377+
12378+ it ( 'should return raw non-Parse Error message in createMany bulk when sanitization is disabled' , async ( ) => {
12379+ try {
12380+ await reconfigureGraphQLWithUnsanitizedErrorsAndOpenClient ( ) ;
12381+
12382+ Parse . Cloud . beforeSave ( 'BulkTest' , request => {
12383+ if ( request . object . get ( 'title' ) === 'FAIL' ) {
12384+ throw new Error ( 'internal stack detail' ) ;
12385+ }
12386+ } ) ;
12387+
12388+ await parseGraphQLServer . parseGraphQLSchema . schemaCache . clear ( ) ;
12389+
12390+ const { data } = await apolloClient . mutate ( {
12391+ mutation : gql `
12392+ mutation CreateManyBulkPlainErrorUnsanitized($input: CreateManyBulkTestInput!) {
12393+ createManyBulkTest(input: $input) {
12394+ results {
12395+ success
12396+ error {
12397+ code
12398+ message
12399+ }
12400+ bulkTest {
12401+ objectId
12402+ title
12403+ }
12404+ }
12405+ }
12406+ }
12407+ ` ,
12408+ variables : {
12409+ input : {
12410+ clientMutationId : uuidv4 ( ) ,
12411+ fields : [ { title : 'ok' } , { title : 'FAIL' } ] ,
12412+ } ,
12413+ } ,
12414+ context : {
12415+ headers : {
12416+ 'X-Parse-Master-Key' : 'test' ,
12417+ } ,
12418+ } ,
12419+ } ) ;
12420+
12421+ const failed = data . createManyBulkTest . results [ 1 ] ;
12422+ expect ( failed . success ) . toBe ( false ) ;
12423+ expect ( failed . error . code ) . toBe ( Parse . Error . SCRIPT_FAILED ) ;
12424+ expect ( failed . error . message ) . toBe ( 'internal stack detail' ) ;
12425+ } catch ( e ) {
12426+ handleError ( e ) ;
12427+ }
12428+ } ) ;
12429+
1232312430 it ( 'should updateMany with partial failure when beforeSave rejects' , async ( ) => {
1232412431 try {
1232512432 const a = new Parse . Object ( 'BulkTest' ) ;
0 commit comments