fix: [CODE-2621]: nil pointer for not found labels during pull requests migration (#2866)

pull/3576/head
Atefeh Mohseni Ejiyeh 2024-10-25 00:33:54 +00:00 committed by Harness
parent 6a17336aaa
commit f78ae3839a
1 changed files with 4 additions and 3 deletions

View File

@ -687,17 +687,18 @@ func (r *repoImportState) defineLabel(
r.scope = int64(len(spaceIDs))
}
label, err := convertLabelWithSanitization(ctx, r.migrator, spaceID, r.scope, extLabel)
labelIn, err := convertLabelWithSanitization(ctx, r.migrator, spaceID, r.scope, extLabel)
if err != nil {
return nil, fmt.Errorf("failed to sanitize and convert external label input: %w", err)
}
label, err = r.labelStore.Find(ctx, &spaceID, nil, label.Key)
label, err := r.labelStore.Find(ctx, &spaceID, nil, labelIn.Key)
if errors.Is(err, gitness_store.ErrResourceNotFound) {
err = r.labelStore.Define(ctx, label)
err = r.labelStore.Define(ctx, labelIn)
if err != nil {
return nil, fmt.Errorf("failed to define and find the label: %w", err)
}
return labelIn, nil
}
if err != nil {
return nil, fmt.Errorf("failed to define and find the label: %w", err)