Skip to content

Commit 2a2743f

Browse files
committed
refactor(data): drop unreachable nil branch in SaveAttestationBundle
ent's UpdateOneID returns a NotFoundError (never a nil run alongside a nil error) when the row is missing, so the extra `run == nil` check was dead code carried over from the previous SaveAttestation implementation. Switch to Exec since the returned row was unused. Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
1 parent a277c38 commit 2a2743f

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

app/controlplane/pkg/data/workflowrun.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,25 +204,17 @@ func (r *WorkflowRunRepo) FindByIDInOrg(ctx context.Context, orgID, id uuid.UUID
204204
}
205205

206206
// SaveAttestationBundle persists the attestation digest on the workflow run and the bundle bytes
207-
// in the linked attestation row within a single transaction. Missing workflow runs surface as NotFound.
207+
// in the linked attestation row within a single transaction.
208208
func (r *WorkflowRunRepo) SaveAttestationBundle(ctx context.Context, id uuid.UUID, digest string, bundle []byte) error {
209209
return WithTx(ctx, r.data.DB, func(tx *ent.Tx) error {
210-
run, err := tx.WorkflowRun.UpdateOneID(id).
211-
SetAttestationDigest(digest).
212-
Save(ctx)
213-
if err != nil {
210+
if err := tx.WorkflowRun.UpdateOneID(id).SetAttestationDigest(digest).Exec(ctx); err != nil {
214211
if ent.IsNotFound(err) {
215212
return biz.NewErrNotFound(fmt.Sprintf("workflow run with id %s not found", id))
216213
}
217214
return err
218215
}
219-
if run == nil {
220-
return biz.NewErrNotFound(fmt.Sprintf("workflow run with id %s not found", id))
221-
}
222216

223-
if err := tx.Attestation.Create().
224-
SetBundle(bundle).SetWorkflowrunID(id).
225-
Exec(ctx); err != nil {
217+
if err := tx.Attestation.Create().SetBundle(bundle).SetWorkflowrunID(id).Exec(ctx); err != nil {
226218
return fmt.Errorf("saving bundle: %w", err)
227219
}
228220
return nil

0 commit comments

Comments
 (0)