@@ -116,7 +116,7 @@ func (r *WorkflowRunRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.Work
116
116
return nil , nil
117
117
}
118
118
119
- return entWrToBizWr (ctx , run ), nil
119
+ return entWrToBizWr (ctx , run )
120
120
}
121
121
122
122
func (r * WorkflowRunRepo ) FindByAttestationDigest (ctx context.Context , digest string ) (* biz.WorkflowRun , error ) {
@@ -127,7 +127,7 @@ func (r *WorkflowRunRepo) FindByAttestationDigest(ctx context.Context, digest st
127
127
return nil , nil
128
128
}
129
129
130
- return entWrToBizWr (ctx , run ), nil
130
+ return entWrToBizWr (ctx , run )
131
131
}
132
132
133
133
func (r * WorkflowRunRepo ) FindByIDInOrg (ctx context.Context , orgID , id uuid.UUID ) (* biz.WorkflowRun , error ) {
@@ -142,7 +142,7 @@ func (r *WorkflowRunRepo) FindByIDInOrg(ctx context.Context, orgID, id uuid.UUID
142
142
return nil , biz .NewErrNotFound ("workflow run" )
143
143
}
144
144
145
- return entWrToBizWr (ctx , run ), nil
145
+ return entWrToBizWr (ctx , run )
146
146
}
147
147
148
148
// Save the attestation for a workflow run in the database
@@ -222,7 +222,11 @@ func (r *WorkflowRunRepo) List(ctx context.Context, orgID uuid.UUID, filters *bi
222
222
continue
223
223
}
224
224
225
- result = append (result , entWrToBizWr (ctx , wr ))
225
+ r , err := entWrToBizWr (ctx , wr )
226
+ if err != nil {
227
+ return nil , "" , fmt .Errorf ("failed to convert workflow run: %w" , err )
228
+ }
229
+ result = append (result , r )
226
230
}
227
231
228
232
return result , cursor , nil
@@ -242,7 +246,12 @@ func (r *WorkflowRunRepo) ListNotFinishedOlderThan(ctx context.Context, olderTha
242
246
243
247
result := make ([]* biz.WorkflowRun , 0 , len (workflowRuns ))
244
248
for _ , wr := range workflowRuns {
245
- result = append (result , entWrToBizWr (ctx , wr ))
249
+ r , err := entWrToBizWr (ctx , wr )
250
+ if err != nil {
251
+ return nil , fmt .Errorf ("failed to convert workflow run: %w" , err )
252
+ }
253
+
254
+ result = append (result , r )
246
255
}
247
256
248
257
return result , nil
@@ -252,7 +261,7 @@ func (r *WorkflowRunRepo) Expire(ctx context.Context, id uuid.UUID) error {
252
261
return r .data .DB .WorkflowRun .UpdateOneID (id ).SetState (biz .WorkflowRunExpired ).ClearAttestationState ().Exec (ctx )
253
262
}
254
263
255
- func entWrToBizWr (ctx context.Context , wr * ent.WorkflowRun ) * biz.WorkflowRun {
264
+ func entWrToBizWr (ctx context.Context , wr * ent.WorkflowRun ) ( * biz.WorkflowRun , error ) {
256
265
r := & biz.WorkflowRun {
257
266
ID : wr .ID ,
258
267
CreatedAt : toTimePtr (wr .CreatedAt ),
@@ -278,7 +287,11 @@ func entWrToBizWr(ctx context.Context, wr *ent.WorkflowRun) *biz.WorkflowRun {
278
287
}
279
288
280
289
if wf := wr .Edges .Workflow ; wf != nil {
281
- w , _ := entWFToBizWF (ctx , wf , nil )
290
+ w , err := entWFToBizWF (ctx , wf , nil )
291
+ if err != nil {
292
+ return nil , fmt .Errorf ("failed to convert workflow: %w" , err )
293
+ }
294
+
282
295
r .Workflow = w
283
296
}
284
297
@@ -288,9 +301,10 @@ func entWrToBizWr(ctx context.Context, wr *ent.WorkflowRun) *biz.WorkflowRun {
288
301
if version == nil {
289
302
version , err = wr .QueryVersion ().Only (ctx )
290
303
if err != nil {
291
- log .Errorf ("failed to query version: %v " , err )
304
+ return nil , fmt .Errorf ("failed to query version: %w " , err )
292
305
}
293
306
}
307
+
294
308
r .ProjectVersion = entProjectVersionToBiz (version )
295
309
296
310
if backends := wr .Edges .CasBackends ; backends != nil {
@@ -299,5 +313,5 @@ func entWrToBizWr(ctx context.Context, wr *ent.WorkflowRun) *biz.WorkflowRun {
299
313
}
300
314
}
301
315
302
- return r
316
+ return r , nil
303
317
}
0 commit comments