{"record":{"id":"9f42e378a10c5e05","repo":"googleapis/mcp-toolbox","slug":"reference-value-must-be-a-string","errorCode":null,"errorMessage":"reference value must be a string","messagePattern":"reference value must be a string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/firestore/util/converter.go","lineNumber":147,"sourceCode":"\t\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\t\treturn nil, fmt.Errorf(\"map field %q: %w\", k, err)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tresult[k] = converted\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn result, nil\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn nil, fmt.Errorf(\"invalid map value format\")\n\t\t\t\tcase \"referenceValue\":\n\t\t\t\t\t// Convert to DocumentRef if client is provided\n\t\t\t\t\tif strVal, ok := val.(string); ok {\n\t\t\t\t\t\tif client != nil && isValidDocumentPath(strVal) {\n\t\t\t\t\t\t\treturn client.Doc(strVal), nil\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Return the path as string if no client or invalid path\n\t\t\t\t\t\treturn strVal, nil\n\t\t\t\t\t}\n\t\t\t\t\treturn nil, fmt.Errorf(\"reference value must be a string\")\n\t\t\t\tdefault:\n\t\t\t\t\t// If not a typed value, treat as regular map\n\t\t\t\t\treturn convertPlainMap(v, client)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Regular map without type annotation\n\t\treturn convertPlainMap(v, client)\n\tdefault:\n\t\t// Plain values (for backward compatibility)\n\t\treturn value, nil\n\t}\n}\n\n// convertPlainMap converts a plain map to Firestore format\nfunc convertPlainMap(m map[string]any, client *firestore.Client) (map[string]any, error) {\n\tresult := make(map[string]any)\n\tfor k, v := range m {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/firestore/util/converter.go#L129-L165","documentation":"Type-check guard in JSONToFirestoreValue for referenceValue: the value is not a string, but a document reference must be expressed as a path string.","triggerScenarios":"Thrown at internal/tools/firestore/util/converter.go:147 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send the document path as a string, e.g. 'users/alice'","Use mapValue or stringValue if the value is not a reference"],"exampleFix":null,"handlingStrategy":"type-guard","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-08T15:18:49.778Z"}