Skip to content

Commit 29f6931

Browse files
committed
improve issue label import error handling
1 parent 208b271 commit 29f6931

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

github/resource_github_issue_label.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package github
33
import (
44
"context"
55
"errors"
6+
"fmt"
67
"net/http"
78

89
"github.com/google/go-github/v88/github"
@@ -61,7 +62,6 @@ func resourceGithubIssueLabel() *schema.Resource {
6162
}
6263
}
6364

64-
// resourceGithubIssueLabelCreate creates an issue label.
6565
func resourceGithubIssueLabelCreate(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
6666
meta, _ := m.(*Owner)
6767
client := meta.v3client
@@ -91,7 +91,8 @@ func resourceGithubIssueLabelCreate(ctx context.Context, d *schema.ResourceData,
9191
}
9292
label.Description = &description
9393
}
94-
githubLabel, resp, err := client.Issues.GetLabel(ctx, orgName, repoName, name)
94+
var githubLabel *github.Label
95+
_, resp, err := client.Issues.GetLabel(ctx, orgName, repoName, name)
9596
if err != nil {
9697
if resp == nil || resp.StatusCode != http.StatusNotFound {
9798
return diag.FromErr(err)
@@ -247,7 +248,7 @@ func resourceGithubIssueLabelDelete(ctx context.Context, d *schema.ResourceData,
247248
func resourceGithubIssueLabelImport(_ context.Context, d *schema.ResourceData, _ any) ([]*schema.ResourceData, error) {
248249
repoName, name, err := parseID2(d.Id())
249250
if err != nil {
250-
return nil, err
251+
return nil, fmt.Errorf("invalid import ID %q; expected format %q: %w", d.Id(), "<repository name>:<label name>", err)
251252
}
252253

253254
if err := d.Set("repository", repoName); err != nil {

0 commit comments

Comments
 (0)