{"record":{"id":"c16a706d58fa04d7","repo":"googleapis/mcp-toolbox","slug":"s-path-cannot-be-empty-or-contain-only-slashes","errorCode":null,"errorMessage":"%s path cannot be empty or contain only slashes","messagePattern":"(.+?) path cannot be empty or contain only slashes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/firestore/util/validator.go","lineNumber":75,"sourceCode":"\tif path == \"\" {\n\t\treturn fmt.Errorf(\"%s path cannot be empty\", pathTypeName)\n\t}\n\n\t// Check if it's an absolute path\n\tif absolutePathRegex.MatchString(path) {\n\t\texample := \"users/userId\"\n\t\tif pathType == CollectionPath {\n\t\t\texample = \"users\"\n\t\t}\n\t\treturn fmt.Errorf(\"path must be relative (e.g., '%s'), not absolute (matching pattern: ^projects/[^/]+/databases/[^/]+/documents/)\", example)\n\t}\n\n\t// Split the path using strings.Split to preserve empty segments\n\tsegments := strings.Split(path, \"/\")\n\n\t// Check for empty result\n\tif len(segments) == 0 {\n\t\treturn fmt.Errorf(\"%s path cannot be empty or contain only slashes\", pathTypeName)\n\t}\n\n\t// Check segment count based on path type\n\tsegmentCount := len(segments)\n\tif pathType == CollectionPath && segmentCount%2 == 0 {\n\t\t// Collection paths must have an odd number of segments\n\t\treturn fmt.Errorf(\"invalid collection path: must have an odd number of segments (e.g., 'collection' or 'collection/doc/subcollection'), got %d segments\", segmentCount)\n\t} else if pathType == DocumentPath && segmentCount%2 != 0 {\n\t\t// Document paths must have an even number of segments\n\t\treturn fmt.Errorf(\"invalid document path: must have an even number of segments (e.g., 'collection/doc'), got %d segments\", segmentCount)\n\t}\n\n\t// Validate each segment\n\tfor i, segment := range segments {\n\t\tisCollectionSegment := (i % 2) == 0\n\t\tif err := validateSegment(segment, isCollectionSegment); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid segment at position %d (%s): %w\", i+1, segment, err)\n\t\t}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/firestore/util/validator.go#L57-L93","documentation":"Guard in the shared Firestore path validator: splitting the path on '/' produced no usable segments, i.e. the path is only slashes (e.g. '/' or '///').","triggerScenarios":"Thrown at internal/tools/firestore/util/validator.go:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove leading/trailing and duplicate slashes","Send a path made of real segment names, e.g. 'users/alice'"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}