googleapis/mcp-toolbox · error

failed to count label %q: %w

Error message

failed to count label %q: %w

What it means

Wrap inside extractNodeLabels: the per-label count query ('MATCH (n:`<label>`) RETURN count(n)') failed for the named label, typically because the label disappeared between listing and counting or contains characters that break the backtick quoting.

Source

Thrown at internal/tools/falkordb/falkordbschema/falkordbschema.go:295

	return schema, nil
}

// extractNodeLabels lists the node labels and derives each label's count and
// property shapes from a sample of nodes.
func (t Tool) extractNodeLabels(ctx context.Context, source compatibleSource) ([]types.NodeLabel, error) {
	labelsResult, err := runReadQuery(ctx, source, "CALL db.labels()")
	if err != nil {
		return nil, fmt.Errorf("failed to list labels: %w", err)
	}

	var nodeLabels []types.NodeLabel
	for _, label := range helpers.FirstColumnStrings(labelsResult) {
		escaped := escapeIdentifier(label)

		countResult, err := runReadQuery(ctx, source, fmt.Sprintf("MATCH (n:`%s`) RETURN count(n) AS count", escaped))
		if err != nil {
			return nil, fmt.Errorf("failed to count label %q: %w", label, err)
		}

		sampleResult, err := runReadQuery(ctx, source, fmt.Sprintf("MATCH (n:`%s`) RETURN n LIMIT %d", escaped, t.Cfg.SampleSize))
		if err != nil {
			return nil, fmt.Errorf("failed to sample label %q: %w", label, err)
		}
		accumulator := make(map[string]map[string]bool)
		for _, row := range helpers.Rows(sampleResult) {
			node, ok := row["n"].(map[string]any)
			if !ok {
				continue
			}
			if properties, ok := node["properties"].(map[string]any); ok {
				helpers.MergeProperties(accumulator, properties)
			}
		}

		nodeLabels = append(nodeLabels, types.NodeLabel{

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Retry the schema extraction if the graph is being mutated concurrently
  2. Check the label for unusual characters and rename it if it cannot be safely quoted
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/tools/falkordb/falkordbschema/falkordbschema.go:295 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/675207fa5546cc6c. Report an issue: GitHub.