{"record":{"id":"a9b23cb880e0e9f7","repo":"googleapis/mcp-toolbox","slug":"failed-to-sample-relationship-type-q-w","errorCode":null,"errorMessage":"failed to sample relationship type %q: %w","messagePattern":"failed to sample relationship type %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/falkordb/falkordbschema/falkordbschema.go","lineNumber":344,"sourceCode":"func (t Tool) extractRelationships(ctx context.Context, source compatibleSource) ([]types.Relationship, error) {\n\ttypesResult, err := runReadQuery(ctx, source, \"CALL db.relationshipTypes()\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to list relationship types: %w\", err)\n\t}\n\n\tvar relationships []types.Relationship\n\tfor _, relType := range helpers.FirstColumnStrings(typesResult) {\n\t\tescaped := escapeIdentifier(relType)\n\n\t\tcountResult, err := runReadQuery(ctx, source, fmt.Sprintf(\"MATCH ()-[r:`%s`]->() RETURN count(r) AS count\", escaped))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to count relationship type %q: %w\", relType, err)\n\t\t}\n\n\t\tsampleResult, err := runReadQuery(ctx, source, fmt.Sprintf(\n\t\t\t\"MATCH (a)-[r:`%s`]->(b) RETURN labels(a) AS startLabels, labels(b) AS endLabels, r LIMIT %d\", escaped, t.Cfg.SampleSize))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to sample relationship type %q: %w\", relType, err)\n\t\t}\n\n\t\taccumulator := make(map[string]map[string]bool)\n\t\tconnectivity := make(map[types.RelConnectivityInfo]int64)\n\t\tfor _, row := range helpers.Rows(sampleResult) {\n\t\t\tif edge, ok := row[\"r\"].(map[string]any); ok {\n\t\t\t\tif properties, ok := edge[\"properties\"].(map[string]any); ok {\n\t\t\t\t\thelpers.MergeProperties(accumulator, properties)\n\t\t\t\t}\n\t\t\t}\n\t\t\tpattern := types.RelConnectivityInfo{\n\t\t\t\tStartNode: firstString(row[\"startLabels\"]),\n\t\t\t\tEndNode:   firstString(row[\"endLabels\"]),\n\t\t\t}\n\t\t\tconnectivity[pattern]++\n\t\t}\n\n\t\trelationship := types.Relationship{","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/falkordb/falkordbschema/falkordbschema.go#L326-L362","documentation":"Thrown when the per-relationship-type sampling query ('MATCH (a)-[r:`<type>`]->(b) RETURN ... LIMIT <SampleSize>') fails inside extractRelationships. The sampling query fetches start/end labels and sample edges to derive connectivity patterns and property shapes. Any driver or query error is wrapped with the relationship type name.","triggerScenarios":"runReadQuery fails on the sample query: connection failure, auth error, query timeout, LIMIT value from Cfg.SampleSize invalid (e.g., 0 or negative in some backends), or server error traversing the relationship type.","commonSituations":"SampleSize misconfigured to an invalid value; long-running traversal timeouts on dense relationship types; transient network issues during multi-query schema extraction.","solutions":["Check the wrapped cause for the driver-level error.","Set Cfg.SampleSize to a small positive integer (e.g., 5-50).","Verify server health and connection stability.","Re-run the schema extraction after fixing the underlying issue."],"exampleFix":"// before\nsampleSize: 0\n// after\nsampleSize: 20","handlingStrategy":"validation","validationCode":"// Validate SampleSize before running extraction\nif t.Cfg.SampleSize <= 0 {\n    return errors.New(\"sampleSize must be a positive integer\")\n}","typeGuard":"func validSampleSize(n int) bool { return n > 0 && n <= 1000 }","tryCatchPattern":"rels, err := tool.ExtractRelationships(ctx, src)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to sample relationship type\") {\n        // reduce SampleSize or skip sampling and degrade to counts only\n    }\n    return err\n}","preventionTips":["Always configure SampleSize as a small positive integer.","Test sampling queries against production-sized graphs before rollout.","Handle sampling failure gracefully by degrading to count-only output.","Verify traversal queries under load."],"tags":["falkordb","graph","query-failure","sampling"],"backgroundTag":"graph-procedure-call-failed","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"}