googleapis/mcp-toolbox · error

path must be relative (e.g., '%s'), not absolute (matching p

Error message

path must be relative (e.g., '%s'), not absolute (matching pattern: ^projects/[^/]+/databases/[^/]+/documents/)

What it means

Guard in the shared Firestore path validator: the path matches the absolute-resource pattern (^projects/.../databases/.../documents/...); the API expects document-relative paths only.

Source

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

// validatePath is the common validation function for both collection and document paths
func validatePath(path string, pathType PathType) error {
	pathTypeName := "document"
	if pathType == CollectionPath {
		pathTypeName = "collection"
	}

	// Check for empty path
	if path == "" {
		return fmt.Errorf("%s path cannot be empty", pathTypeName)
	}

	// Check if it's an absolute path
	if absolutePathRegex.MatchString(path) {
		example := "users/userId"
		if pathType == CollectionPath {
			example = "users"
		}
		return fmt.Errorf("path must be relative (e.g., '%s'), not absolute (matching pattern: ^projects/[^/]+/databases/[^/]+/documents/)", example)
	}

	// Split the path using strings.Split to preserve empty segments
	segments := strings.Split(path, "/")

	// Check for empty result
	if len(segments) == 0 {
		return fmt.Errorf("%s path cannot be empty or contain only slashes", pathTypeName)
	}

	// Check segment count based on path type
	segmentCount := len(segments)
	if pathType == CollectionPath && segmentCount%2 == 0 {
		// Collection paths must have an odd number of segments
		return fmt.Errorf("invalid collection path: must have an odd number of segments (e.g., 'collection' or 'collection/doc/subcollection'), got %d segments", segmentCount)
	} else if pathType == DocumentPath && segmentCount%2 != 0 {
		// Document paths must have an even number of segments
		return fmt.Errorf("invalid document path: must have an even number of segments (e.g., 'collection/doc'), got %d segments", segmentCount)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Strip the projects/<p>/databases/<d>/documents/ prefix and send just the tail, e.g. 'users/alice'
  2. Use the relative form shown in the error example
Defensive patterns

Strategy: validation

When it happens

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