GoogleContainerTools/skaffold · error
deleting label: %w
Error message
deleting label: %w
What it means
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.
Source
Thrown at pkg/webhook/github/github.go:74
func (g *Client) CommentOnPR(pr *github.PullRequestEvent, message string) error {
comment := &github.IssueComment{
Body: &message,
}
log.Printf("Creating comment on PR %d: %s", pr.PullRequest.GetNumber(), message)
_, _, err := g.Client.Issues.CreateComment(g.ctx, constants.GithubOwner, constants.GithubRepo, pr.PullRequest.GetNumber(), comment)
if err != nil {
return fmt.Errorf("creating github comment: %w", err)
}
log.Printf("Successfully commented on PR %d.", pr.GetNumber())
return nil
}
// RemoveLabelFromPR removes label from pr
func (g *Client) RemoveLabelFromPR(pr *github.PullRequestEvent, label string) error {
_, err := g.Client.Issues.RemoveLabelForIssue(g.ctx, constants.GithubOwner, constants.GithubRepo, pr.GetNumber(), label)
if err != nil {
return fmt.Errorf("deleting label: %w", err)
}
log.Printf("Successfully deleted label from PR %d", pr.GetNumber())
return nil
}
View on GitHub (pinned to a1189de023)
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.
Example fix
// before
if err := g.RemoveLabelFromPR(pr, "skaffold-ok"); err != nil { return err }
// after
if err := g.RemoveLabelFromPR(pr, "skaffold-ok"); err != nil {
var ghErr *github.ErrorResponse
if errors.As(err, &ghErr) && ghErr.Response.StatusCode == http.StatusNotFound {
return nil // label already gone
}
return err
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight: check the label exists on the PR before removing
labels, _, err := gc.Issues.ListLabelsForIssue(ctx, owner, repo, num, nil)
if err == nil && !containsLabel(labels, label) { return nil } Try / catch
// Go
if err := g.RemoveLabelFromPR(pr, label); err != nil {
var respErr *github.ErrorResponse
if errors.As(err, &respErr) && respErr.Response.StatusCode == 404 {
return nil // label already absent; idempotent removal
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- creating github comment: %w
- DEPLOY_CLOUD_RUN_GET_SERVICE_ERR
- DEPLOY_CLOUD_RUN_UPDATE_SERVICE_ERR
- StatusCode_DEPLOY_CLOUD_RUN_DELETE_SERVICE_ERR
- StatusCode_DEPLOY_CLOUD_RUN_DELETE_WORKER_POOL_ERR
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/2a1d5092b8b69bac.
Report an issue: GitHub.