Skip to content

Commit a528637

Browse files
committed
cmd/gopherbot: handle 404 GitHub issues in freezeOldIssues task
A GitHub issue can become 404. Attempting to lock it will produce a 404 response from the GitHub API. Don't treat it as a fatal error when it happens. Add a check for the NotExist field. This will help after golang/go#30184 is resolved. Updates golang/go#30182 Change-Id: Ia04c59879909b1de00bd681606bfa331fe642cd4 Reviewed-on: https://go-review.googlesource.com/c/161906 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent dc550c1 commit a528637

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd/gopherbot/gopherbot.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ func (b *gopherbot) unwaitRelease(ctx context.Context) error {
701701
func (b *gopherbot) freezeOldIssues(ctx context.Context) error {
702702
tooOld := time.Now().Add(-365 * 24 * time.Hour)
703703
return b.gorepo.ForeachIssue(func(gi *maintner.GitHubIssue) error {
704-
if !gi.Closed || gi.PullRequest || gi.Locked {
704+
if gi.NotExist || !gi.Closed || gi.PullRequest || gi.Locked {
705705
return nil
706706
}
707707
if gi.Updated.After(tooOld) {
@@ -712,7 +712,11 @@ func (b *gopherbot) freezeOldIssues(ctx context.Context) error {
712712
return nil
713713
}
714714
_, err := b.ghc.Issues.Lock(ctx, "golang", "go", int(gi.Number), nil)
715-
if err != nil {
715+
if ge, ok := err.(*github.ErrorResponse); ok && ge.Response.StatusCode == http.StatusNotFound {
716+
// It's rare, but an issue can become 404 on GitHub. See golang.org/issue/30182.
717+
// Nothing to do since the issue is gone.
718+
return nil
719+
} else if err != nil {
716720
return err
717721
}
718722
return b.addLabel(ctx, gi, frozenDueToAge)

0 commit comments

Comments
 (0)