googleapis/mcp-toolbox · error

segment cannot be empty

Error message

segment cannot be empty

What it means

Segment guard in validateSegment: a path segment between slashes is the empty string, typically caused by a leading, trailing, or doubled slash.

Source

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

		isCollectionSegment := (i % 2) == 0
		if err := validateSegment(segment, isCollectionSegment); err != nil {
			return fmt.Errorf("invalid segment at position %d (%s): %w", i+1, segment, err)
		}
	}

	return nil
}

// validateSegment validates a single path segment
func validateSegment(segment string, isCollection bool) error {
	segmentType := "document ID"
	if isCollection {
		segmentType = "collection ID"
	}

	// 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

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Remove leading/trailing and duplicate slashes
  2. Write the path with real segment names only, e.g. 'users/alice'
Defensive patterns

Strategy: validation

When it happens

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