{"record":{"id":"cc365435b12175d9","repo":"googleapis/mcp-toolbox","slug":"failed-to-count-relationship-type-q-w","errorCode":null,"errorMessage":"failed to count relationship type %q: %w","messagePattern":"failed to count relationship type %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/falkordb/falkordbschema/falkordbschema.go","lineNumber":338,"sourceCode":"\treturn nodeLabels, nil\n}\n\n// extractRelationships lists the relationship types and derives each type's\n// count, most common connectivity pattern, and property shapes from a sample\n// of relationships.\nfunc (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\"]),","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/falkordb/falkordbschema/falkordbschema.go#L320-L356","documentation":"This error occurs in extractRelationships when counting edges of a specific relationship type. After listing relationship types, the tool runs 'MATCH ()-[r:`<type>`]->() RETURN count(r)' per type; any query failure is wrapped with the failing relationship type name. The type name is escaped into backticks, so the underlying cause is a driver/query error, not a naming issue.","triggerScenarios":"runReadQuery fails on the count query for a relationship type returned by db.relationshipTypes(): connection drop mid-schema-extraction, auth failure, server timeout, or backend error executing the count aggregation.","commonSituations":"Large graphs where the count query times out; connection pool exhaustion while iterating many relationship types; server restarted between queries; read-only replica rejecting the query.","solutions":["Check server logs and the wrapped cause to identify the driver-level failure.","Increase query timeout settings if the count times out on large graphs.","Verify connection stability/auth between toolbox and FalkorDB.","Re-run the schema tool; consider sampling instead of exact counts for very large graphs."],"exampleFix":"// before: timeout counting large relationship type\n// after: increase client timeout in source config\nsource:\n  kind: falkordb\n  address: localhost:6379\n  # ensure adequate timeout for count(r) on large graphs","handlingStrategy":"retry","validationCode":"// Pre-check the relationship type count query manually\n// MATCH ()-[r:`TYPE`]->() RETURN count(r) LIMIT 1 — verify it executes under your timeout budget","typeGuard":"func isTimeout(err error) bool {\n    var ne net.Error\n    return errors.As(err, &ne) && ne.Timeout()\n}","tryCatchPattern":"rel, err := extractOne(ctx, src, relType)\nif err != nil {\n    if isTimeout(err) {\n        rel, err = retryWithBackoff(3, func() error { _, err = extractOne(ctx, src, relType); return err })\n    }\n    if err != nil { return fmt.Errorf(\"type %s: %w\", relType, err) }\n}","preventionTips":["Set generous but bounded query timeouts for count aggregations.","Skip or approximate counts for very large relationship types.","Monitor connection pool health during multi-query extraction.","Retry transient driver errors with backoff."],"tags":["falkordb","graph","query-failure","timeout"],"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"}