{"record":{"id":"b3bfef55cfb49403","repo":"googleapis/mcp-toolbox","slug":"invalid-segment-at-position-d-s-w","errorCode":null,"errorMessage":"invalid segment at position %d (%s): %w","messagePattern":"invalid segment at position (.+?) \\((.+?)\\): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/firestore/util/validator.go","lineNumber":92,"sourceCode":"\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}\n\t}\n\n\treturn nil\n}\n\n// validateSegment validates a single path segment\nfunc validateSegment(segment string, isCollection bool) error {\n\tsegmentType := \"document ID\"\n\tif isCollection {\n\t\tsegmentType = \"collection ID\"\n\t}\n\n\t// Check for empty segment\n\tif segment == \"\" {\n\t\treturn fmt.Errorf(\"segment cannot be empty\")\n\t}\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/firestore/util/validator.go#L74-L110","documentation":"Wrap in the shared Firestore path validator: one specific segment failed segment-level validation; the position, the segment text, and the wrapped reason (empty, whitespace, '.'/'..', or reserved '__' prefix) are included.","triggerScenarios":"Thrown at internal/tools/firestore/util/validator.go:92 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the segment at the reported position per the wrapped reason","Avoid empty segments (double slashes), whitespace, dot segments, and '__'-prefixed names"],"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"}