googleapis/mcp-toolbox · error

%s cannot start with '__' (reserved prefix)

Error message

%s cannot start with '__' (reserved prefix)

What it means

Segment guard in validateSegment: the collection ID or document ID starts with '__', a prefix Firestore reserves for internal collections and does not allow in user paths.

Source

Thrown at internal/tools/firestore/util/validator.go:123

	// Check for empty segment
	if segment == "" {
		return fmt.Errorf("segment cannot be empty")
	}

	// Check for whitespace-only segment
	if strings.TrimSpace(segment) == "" {
		return fmt.Errorf("segment cannot be only whitespace")
	}

	// Check for single or double period
	if segment == "." || segment == ".." {
		return fmt.Errorf("segment cannot be '.' or '..'")
	}

	// Check for reserved prefix
	if strings.HasPrefix(segment, "__") {
		return fmt.Errorf("%s cannot start with '__' (reserved prefix)", segmentType)
	}

	return nil
}

// IsAbsolutePath checks if a path is an absolute Firestore path
func IsAbsolutePath(path string) bool {
	return absolutePathRegex.MatchString(path)
}

// IsRelativePath checks if a path is a relative Firestore path
func IsRelativePath(path string) bool {
	return path != "" && !IsAbsolutePath(path)
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Rename the segment to drop the leading '__'
  2. Use a different prefix such as 'meta_' for user-created identifiers
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/tools/firestore/util/validator.go:123 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/737b1256e0f7d3cf. Report an issue: GitHub.