File tree Expand file tree Collapse file tree 3 files changed +27
-12
lines changed Expand file tree Collapse file tree 3 files changed +27
-12
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " wrangler " : minor
3+ ---
4+
5+ fix: making explicit to only send a body if there are rule ids specified in the config delete
Original file line number Diff line number Diff line change @@ -1039,6 +1039,7 @@ describe("r2", () => {
10391039 async ( { request, params } ) => {
10401040 const { accountId } = params ;
10411041 expect ( accountId ) . toEqual ( "some-account-id" ) ;
1042+ expect ( request . body ) . toBeNull ( ) ;
10421043 expect ( request . headers . get ( "authorization" ) ) . toEqual (
10431044 "Bearer some-api-token"
10441045 ) ;
@@ -1100,6 +1101,9 @@ describe("r2", () => {
11001101 async ( { request, params } ) => {
11011102 const { accountId } = params ;
11021103 expect ( accountId ) . toEqual ( "some-account-id" ) ;
1104+ expect ( request . body ) . not . toBeNull ( ) ;
1105+ const requestBody = await request . text ( ) ;
1106+ expect ( requestBody ) . toContain ( `"ruleIds":["${ ruleId } "]` ) ;
11031107 expect ( request . headers . get ( "authorization" ) ) . toEqual (
11041108 "Bearer some-api-token"
11051109 ) ;
Original file line number Diff line number Diff line change @@ -584,18 +584,24 @@ export async function deleteEventNotificationConfig(
584584 logger . log (
585585 `Disabling event notifications for "${ bucketName } " to queue ${ queueName } ...`
586586 ) ;
587-
588- const body : DeleteNotificationRequestBody =
589- ruleId !== undefined
590- ? {
591- ruleIds : [ ruleId ] ,
592- }
593- : { } ;
594-
595- return await fetchResult < null > (
596- `/accounts/${ accountId } /event_notifications/r2/${ bucketName } /configuration/queues/${ queue . queue_id } ` ,
597- { method : "DELETE" , body : JSON . stringify ( body ) , headers }
598- ) ;
587+ if ( ruleId !== undefined ) {
588+ const body : DeleteNotificationRequestBody =
589+ ruleId !== undefined
590+ ? {
591+ ruleIds : [ ruleId ] ,
592+ }
593+ : { } ;
594+
595+ return await fetchResult < null > (
596+ `/accounts/${ accountId } /event_notifications/r2/${ bucketName } /configuration/queues/${ queue . queue_id } ` ,
597+ { method : "DELETE" , body : JSON . stringify ( body ) , headers }
598+ ) ;
599+ } else {
600+ return await fetchResult < null > (
601+ `/accounts/${ accountId } /event_notifications/r2/${ bucketName } /configuration/queues/${ queue . queue_id } ` ,
602+ { method : "DELETE" , headers }
603+ ) ;
604+ }
599605}
600606
601607/**
You can’t perform that action at this time.
0 commit comments