{"record":{"id":"2a1d5092b8b69bac","repo":"GoogleContainerTools/skaffold","slug":"deleting-label-w","errorCode":null,"errorMessage":"deleting label: %w","messagePattern":"deleting label: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/webhook/github/github.go","lineNumber":74,"sourceCode":"func (g *Client) CommentOnPR(pr *github.PullRequestEvent, message string) error {\n\tcomment := &github.IssueComment{\n\t\tBody: &message,\n\t}\n\n\tlog.Printf(\"Creating comment on PR %d: %s\", pr.PullRequest.GetNumber(), message)\n\t_, _, err := g.Client.Issues.CreateComment(g.ctx, constants.GithubOwner, constants.GithubRepo, pr.PullRequest.GetNumber(), comment)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating github comment: %w\", err)\n\t}\n\tlog.Printf(\"Successfully commented on PR %d.\", pr.GetNumber())\n\treturn nil\n}\n\n// RemoveLabelFromPR removes label from pr\nfunc (g *Client) RemoveLabelFromPR(pr *github.PullRequestEvent, label string) error {\n\t_, err := g.Client.Issues.RemoveLabelForIssue(g.ctx, constants.GithubOwner, constants.GithubRepo, pr.GetNumber(), label)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"deleting label: %w\", err)\n\t}\n\tlog.Printf(\"Successfully deleted label from PR %d\", pr.GetNumber())\n\treturn nil\n}\n","sourceCodeStart":56,"sourceCodeEnd":79,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/webhook/github/github.go#L56-L79","documentation":"Returned by Client.RemoveLabelFromPR when the GitHub API call Issues.RemoveLabelForIssue fails while deleting a label from a pull request. The underlying GitHub error is wrapped for unwrapping, so 404s (label or PR not found), auth failures, and rate limits are all surfaced here.","triggerScenarios":"Calling RemoveLabelFromPR with a label name that does not exist on the issue (GitHub returns 404), an unauthorized/insufficient-scope token, a bad owner/repo, a stale PR number, or a network failure.","commonSituations":"The webhook tries to remove a label (e.g. an auto-applied 'deploy/skaffold' status label) that was already removed or never added; token lacks write access; label renamed in the repo settings while webhook code still references the old name.","solutions":["Check the unwrapped GitHub error status; treat 404 as benign (label already absent) if removal is idempotent in your flow.","Verify the label string exactly matches the repo's label name (case-sensitive, spaces included).","Ensure the token has repo write / `pull-requests: write` scope.","Verify constants.GithubOwner/GithubRepo and that pr.GetNumber() is current.","On 403 rate-limit errors, back off until the rate-limit reset time and retry."],"exampleFix":"// before\nif err := g.RemoveLabelFromPR(pr, \"skaffold-ok\"); err != nil { return err }\n// after\nif err := g.RemoveLabelFromPR(pr, \"skaffold-ok\"); err != nil {\n    var ghErr *github.ErrorResponse\n    if errors.As(err, &ghErr) && ghErr.Response.StatusCode == http.StatusNotFound {\n        return nil // label already gone\n    }\n    return err\n}","handlingStrategy":"try-catch","validationCode":"// pre-flight: check the label exists on the PR before removing\nlabels, _, err := gc.Issues.ListLabelsForIssue(ctx, owner, repo, num, nil)\nif err == nil && !containsLabel(labels, label) { return nil }","typeGuard":null,"tryCatchPattern":"// Go\nif err := g.RemoveLabelFromPR(pr, label); err != nil {\n    var respErr *github.ErrorResponse\n    if errors.As(err, &respErr) && respErr.Response.StatusCode == 404 {\n        return nil // label already absent; idempotent removal\n    }\n    return err\n}","preventionTips":["Treat 404 as success when label removal is idempotent.","Keep label names in a shared constant matching repo label configuration.","Ensure the webhook token has write access; rotate before expiry."],"tags":["github","api","webhook","labels"],"backgroundTag":"github-api-request-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}