@@ -112,7 +112,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
112112 if ( findOrCreateError instanceof ServiceValidationError ) {
113113 // `#failBackgroundWorkerDeployment` already throws its argument; the
114114 // outer `throw` covers the non-SVE branch.
115- await this . #failBackgroundWorkerDeployment( deployment , findOrCreateError ) ;
115+ await this . #failBackgroundWorkerDeployment( deployment , findOrCreateError , environment ) ;
116116 }
117117 throw findOrCreateError ;
118118 }
@@ -145,7 +145,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
145145
146146 const serviceError = new ServiceValidationError ( "Error creating background worker files" ) ;
147147
148- await this . #failBackgroundWorkerDeployment( deployment , serviceError ) ;
148+ await this . #failBackgroundWorkerDeployment( deployment , serviceError , environment ) ;
149149
150150 throw serviceError ;
151151 }
@@ -168,7 +168,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
168168 error : resourcesError . message ,
169169 } ) ;
170170
171- await this . #failBackgroundWorkerDeployment( deployment , resourcesError ) ;
171+ await this . #failBackgroundWorkerDeployment( deployment , resourcesError , environment ) ;
172172 throw resourcesError ;
173173 }
174174
@@ -180,7 +180,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
180180 "Error creating background worker resources"
181181 ) ;
182182
183- await this . #failBackgroundWorkerDeployment( deployment , serviceError ) ;
183+ await this . #failBackgroundWorkerDeployment( deployment , serviceError , environment ) ;
184184
185185 throw serviceError ;
186186 }
@@ -207,7 +207,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
207207 error : schedulesError . message ,
208208 } ) ;
209209
210- await this . #failBackgroundWorkerDeployment( deployment , schedulesError ) ;
210+ await this . #failBackgroundWorkerDeployment( deployment , schedulesError , environment ) ;
211211 throw schedulesError ;
212212 }
213213
@@ -221,7 +221,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
221221
222222 const serviceError = new ServiceValidationError ( "Error syncing declarative schedules" ) ;
223223
224- await this . #failBackgroundWorkerDeployment( deployment , serviceError ) ;
224+ await this . #failBackgroundWorkerDeployment( deployment , serviceError , environment ) ;
225225
226226 throw serviceError ;
227227 }
@@ -265,7 +265,11 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
265265 } ) ;
266266 }
267267
268- async #failBackgroundWorkerDeployment( deployment : WorkerDeployment , error : Error ) {
268+ async #failBackgroundWorkerDeployment(
269+ deployment : WorkerDeployment ,
270+ error : Error ,
271+ environment : AuthenticatedEnvironment
272+ ) {
269273 // Guarded BUILDING → FAILED transition, symmetric with the BUILDING → DEPLOYING
270274 // transition in `call()`. With idempotent retries, two attempts can run side-by-side;
271275 // without the predicate, one attempt's failure could downgrade the deployment after
@@ -302,8 +306,10 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
302306 recordDeploymentOutcome ( {
303307 status : "FAILED" ,
304308 deploymentFriendlyId : deployment . friendlyId ,
305- projectId : deployment . projectId ,
306- environmentId : deployment . environmentId ,
309+ organizationId : environment . organizationId ,
310+ projectId : environment . projectId ,
311+ environmentId : environment . id ,
312+ environmentType : environment . type ,
307313 reason : error . message ,
308314 } ) ;
309315 }
0 commit comments