Skip to content

Commit 14d9eb0

Browse files
committed
fix order
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
1 parent dbb7765 commit 14d9eb0

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

app/controlplane/pkg/biz/workflow.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ func (uc *WorkflowUseCase) Create(ctx context.Context, opts *WorkflowCreateOpts)
161161
return nil, fmt.Errorf("failed to parse org ID %q: %w", opts.OrgID, err)
162162
}
163163

164-
existingProject, err := uc.projectRepo.FindProjectByOrgIDAndName(ctx, orgUUID, opts.Project)
165-
projectAlreadyExists := err == nil && existingProject != nil
166-
167164
wf, err := uc.wfRepo.Create(ctx, opts)
168165
if err != nil {
169166
if IsErrAlreadyExists(err) {
@@ -180,8 +177,13 @@ func (uc *WorkflowUseCase) Create(ctx context.Context, opts *WorkflowCreateOpts)
180177
}
181178
}
182179

180+
existingProject, err := uc.projectRepo.FindProjectByOrgIDAndName(ctx, orgUUID, opts.Project)
181+
if err != nil {
182+
return nil, fmt.Errorf("failed to find project: %w", err)
183+
}
184+
183185
// Dispatch audit event for project creation if a new project was created
184-
if !projectAlreadyExists {
186+
if existingProject == nil {
185187
uc.auditorUC.Dispatch(ctx, &events.ProjectCreated{
186188
ProjectBase: &events.ProjectBase{
187189
ProjectID: &wf.ProjectID,

0 commit comments

Comments
 (0)