github/github-mcp-server · error

label '%s' not found in %s/%s

Error message

label '%s' not found in %s/%s

What it means

getLabelID runs a GraphQL label(name:) lookup (used by label update/delete to resolve the node ID) and treats an empty returned name as not-found. The message names the label and owner/repo. Note the GraphQL API matches label names case-sensitively, so 'bug' will not find 'Bug'.

Source

Thrown at pkg/github/labels.go:458

func getLabelID(ctx context.Context, client *githubv4.Client, owner, repo, labelName string) (githubv4.ID, error) {
	var query struct {
		Repository struct {
			Label struct {
				ID   githubv4.ID
				Name githubv4.String
			} `graphql:"label(name: $name)"`
		} `graphql:"repository(owner: $owner, name: $repo)"`
	}
	vars := map[string]any{
		"owner": githubv4.String(owner),
		"repo":  githubv4.String(repo),
		"name":  githubv4.String(labelName),
	}
	if err := client.Query(ctx, &query, vars); err != nil {
		return "", err
	}
	if query.Repository.Label.Name == "" {
		return "", fmt.Errorf("label '%s' not found in %s/%s", labelName, owner, repo)
	}
	return query.Repository.Label.ID, nil
}

View on GitHub (pinned to 0ea1f775a7)

Solutions

  1. List labels first (list_labels) and copy the exact, case-correct name
  2. Create the label first if it should exist
  3. Verify owner/repo spelling and that the token can access the repository

Example fix

// before
{"owner":"octo","repo":"kit","name":"bug","color":"ff0000","method":"update"}
// after
{"owner":"octo","repo":"kit","name":"Bug","color":"ff0000","method":"update"}
Defensive patterns

Strategy: validation

Validate before calling

func resolveLabelNameExact(owner, repo, want string) (string, error) {
	labels := listLabels(owner, repo) // via list_labels tool or GET /repos/{o}/{r}/labels
	for _, l := range labels {
		if l.Name == want {
			return l.Name, nil
		}
		if strings.EqualFold(l.Name, want) {
			return l.Name, nil // case-insensitive rescue
		}
	}
	return "", fmt.Errorf("label %q not found; available: %v", want, names(labels))
}

Type guard

func labelExists(name string, existing []string) bool {
	for _, l := range existing {
		if l == name {
			return true
		}
	}
	return false
}

Try / catch

if err != nil && strings.Contains(err.Error(), "not found in") {
    // Re-list labels, pick the exact name (case-sensitive), then retry the mutation.
}

Prevention

When it happens

Trigger: Calling update_label/delete_label with a name that does not exist exactly as typed in owner/repo, or a name the token cannot see (no access to the repo).

Common situations: Case mismatch ('Bug' vs 'bug'); label renamed or deleted concurrently; wrong owner/repo; token lacking read access so the repository field yields empty.

Related errors


AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15). Data as JSON: /api/errors/a9f9f3361fd68574. Report an issue: GitHub.