@@ -455,7 +455,10 @@ export class DeliverAlertService extends BaseService {
455455 error,
456456 } ;
457457
458- await this . #deliverWebhook( payload , webhookProperties . data ) ;
458+ await this . #deliverWebhook( payload , webhookProperties . data , {
459+ webhookId : alert . channel . id ,
460+ runId : alert . taskRun . friendlyId ,
461+ } ) ;
459462 break ;
460463 }
461464 case "v2" : {
@@ -516,7 +519,10 @@ export class DeliverAlertService extends BaseService {
516519 } ,
517520 } ;
518521
519- await this . #deliverWebhook( payload , webhookProperties . data ) ;
522+ await this . #deliverWebhook( payload , webhookProperties . data , {
523+ webhookId : alert . channel . id ,
524+ runId : alert . taskRun . friendlyId ,
525+ } ) ;
520526
521527 break ;
522528 }
@@ -577,7 +583,9 @@ export class DeliverAlertService extends BaseService {
577583 vercel : this . #buildWebhookVercelObject( deploymentMeta . vercelDeploymentUrl ) ,
578584 } ;
579585
580- await this . #deliverWebhook( payload , webhookProperties . data ) ;
586+ await this . #deliverWebhook( payload , webhookProperties . data , {
587+ webhookId : alert . channel . id ,
588+ } ) ;
581589 break ;
582590 }
583591 case "v2" : {
@@ -616,7 +624,9 @@ export class DeliverAlertService extends BaseService {
616624 } ,
617625 } ;
618626
619- await this . #deliverWebhook( payload , webhookProperties . data ) ;
627+ await this . #deliverWebhook( payload , webhookProperties . data , {
628+ webhookId : alert . channel . id ,
629+ } ) ;
620630
621631 break ;
622632 }
@@ -671,7 +681,9 @@ export class DeliverAlertService extends BaseService {
671681 vercel : this . #buildWebhookVercelObject( deploymentMeta . vercelDeploymentUrl ) ,
672682 } ;
673683
674- await this . #deliverWebhook( payload , webhookProperties . data ) ;
684+ await this . #deliverWebhook( payload , webhookProperties . data , {
685+ webhookId : alert . channel . id ,
686+ } ) ;
675687 break ;
676688 }
677689 case "v2" : {
@@ -716,7 +728,9 @@ export class DeliverAlertService extends BaseService {
716728 } ,
717729 } ;
718730
719- await this . #deliverWebhook( payload , webhookProperties . data ) ;
731+ await this . #deliverWebhook( payload , webhookProperties . data , {
732+ webhookId : alert . channel . id ,
733+ } ) ;
720734
721735 break ;
722736 }
@@ -1017,7 +1031,11 @@ export class DeliverAlertService extends BaseService {
10171031 }
10181032 }
10191033
1020- async #deliverWebhook< T > ( payload : T , webhook : ProjectAlertWebhookProperties ) {
1034+ async #deliverWebhook< T > (
1035+ payload : T ,
1036+ webhook : ProjectAlertWebhookProperties ,
1037+ context : { webhookId : string ; runId ?: string }
1038+ ) {
10211039 const rawPayload = JSON . stringify ( payload ) ;
10221040 const hashPayload = Buffer . from ( rawPayload , "utf-8" ) ;
10231041
@@ -1046,15 +1064,17 @@ export class DeliverAlertService extends BaseService {
10461064 } ) ;
10471065
10481066 if ( ! response . ok ) {
1067+ // Never log the request/response body here: it is customer-controlled alert
1068+ // content and may include stack traces or other application data.
10491069 logger . info ( "[DeliverAlert] Failed to send alert webhook" , {
10501070 status : response . status ,
10511071 statusText : response . statusText ,
1052- url : webhook . url ,
1053- body : payload ,
1054- signature ,
1072+ urlHost : safeUrlHost ( webhook . url ) ,
1073+ webhookId : context . webhookId ,
1074+ runId : context . runId ,
10551075 } ) ;
10561076
1057- throw new Error ( `Failed to send alert webhook to ${ webhook . url } ` ) ;
1077+ throw new Error ( `Failed to send alert webhook to ${ safeUrlHost ( webhook . url ) } ` ) ;
10581078 }
10591079 }
10601080
@@ -1435,3 +1455,11 @@ function isWebAPIHTTPError(error: unknown): error is WebAPIHTTPError {
14351455function isWebAPIRateLimitedError ( error : unknown ) : error is WebAPIRateLimitedError {
14361456 return ( error as WebAPIRateLimitedError ) . code === ErrorCode . RateLimitedError ;
14371457}
1458+
1459+ function safeUrlHost ( url : string ) : string {
1460+ try {
1461+ return new URL ( url ) . host ;
1462+ } catch {
1463+ return "unknown" ;
1464+ }
1465+ }
0 commit comments