@@ -116,7 +116,7 @@ func (r *WorkflowRunRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.Work
116116 return nil , nil
117117 }
118118
119- return entWrToBizWr (ctx , run ), nil
119+ return entWrToBizWr (ctx , run )
120120}
121121
122122func (r * WorkflowRunRepo ) FindByAttestationDigest (ctx context.Context , digest string ) (* biz.WorkflowRun , error ) {
@@ -127,7 +127,7 @@ func (r *WorkflowRunRepo) FindByAttestationDigest(ctx context.Context, digest st
127127 return nil , nil
128128 }
129129
130- return entWrToBizWr (ctx , run ), nil
130+ return entWrToBizWr (ctx , run )
131131}
132132
133133func (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
142142 return nil , biz .NewErrNotFound ("workflow run" )
143143 }
144144
145- return entWrToBizWr (ctx , run ), nil
145+ return entWrToBizWr (ctx , run )
146146}
147147
148148// 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
222222 continue
223223 }
224224
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 )
226230 }
227231
228232 return result , cursor , nil
@@ -242,7 +246,12 @@ func (r *WorkflowRunRepo) ListNotFinishedOlderThan(ctx context.Context, olderTha
242246
243247 result := make ([]* biz.WorkflowRun , 0 , len (workflowRuns ))
244248 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 )
246255 }
247256
248257 return result , nil
@@ -252,7 +261,7 @@ func (r *WorkflowRunRepo) Expire(ctx context.Context, id uuid.UUID) error {
252261 return r .data .DB .WorkflowRun .UpdateOneID (id ).SetState (biz .WorkflowRunExpired ).ClearAttestationState ().Exec (ctx )
253262}
254263
255- func entWrToBizWr (ctx context.Context , wr * ent.WorkflowRun ) * biz.WorkflowRun {
264+ func entWrToBizWr (ctx context.Context , wr * ent.WorkflowRun ) ( * biz.WorkflowRun , error ) {
256265 r := & biz.WorkflowRun {
257266 ID : wr .ID ,
258267 CreatedAt : toTimePtr (wr .CreatedAt ),
@@ -278,7 +287,11 @@ func entWrToBizWr(ctx context.Context, wr *ent.WorkflowRun) *biz.WorkflowRun {
278287 }
279288
280289 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+
282295 r .Workflow = w
283296 }
284297
@@ -288,9 +301,10 @@ func entWrToBizWr(ctx context.Context, wr *ent.WorkflowRun) *biz.WorkflowRun {
288301 if version == nil {
289302 version , err = wr .QueryVersion ().Only (ctx )
290303 if err != nil {
291- log .Errorf ("failed to query version: %v " , err )
304+ return nil , fmt .Errorf ("failed to query version: %w " , err )
292305 }
293306 }
307+
294308 r .ProjectVersion = entProjectVersionToBiz (version )
295309
296310 if backends := wr .Edges .CasBackends ; backends != nil {
@@ -299,5 +313,5 @@ func entWrToBizWr(ctx context.Context, wr *ent.WorkflowRun) *biz.WorkflowRun {
299313 }
300314 }
301315
302- return r
316+ return r , nil
303317}
0 commit comments