{"record":{"id":"fb70b555c39031bc","repo":"ruvnet/ruflo","slug":"index-indexname-not-found","errorCode":null,"errorMessage":"Index ${indexName} not found","messagePattern":"Index (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/plugins/src/integrations/ruvector/ruvector-bridge.ts","lineNumber":946,"sourceCode":"      indexrelname: string;\n      idx_scan: number;\n      idx_tup_read: number;\n      idx_tup_fetch: number;\n      pg_relation_size: number;\n    }>(\n      `SELECT\n        indexrelname,\n        idx_scan,\n        idx_tup_read,\n        idx_tup_fetch,\n        pg_relation_size(indexrelid) as pg_relation_size\n      FROM pg_stat_user_indexes\n      WHERE indexrelname = $1`,\n      [indexName]\n    );\n\n    if (result.rows.length === 0) {\n      throw new Error(`Index ${indexName} not found`);\n    }\n\n    const row = result.rows[0];\n    return {\n      indexName: row.indexrelname,\n      indexType: 'hnsw', // Would need additional query to determine\n      numVectors: row.idx_tup_read,\n      sizeBytes: row.pg_relation_size,\n      buildTimeMs: 0, // Not available from stats\n      lastRebuild: new Date(),\n      params: {\n        scans: row.idx_scan,\n        tuplesRead: row.idx_tup_read,\n        tuplesFetched: row.idx_tup_fetch,\n      },\n    };\n  }\n","sourceCodeStart":928,"sourceCodeEnd":964,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/plugins/src/integrations/ruvector/ruvector-bridge.ts#L928-L964","documentation":"Thrown by the index-stats lookup when the query against pg_stat_user_indexes returns zero rows for the given index name. The stats view only lists indexes that exist in the current schema's user tables, so no row means the index was never created, lives in a different schema, or the name is misspelled.","triggerScenarios":"Calling getIndexStats before createIndex ran; checking an index created in a non-default schema while the connection's search_path points elsewhere; querying stats for an index that createIndex(replace: true) just dropped.","commonSituations":"Deployment ordering — a monitoring/maintenance job polls stats before the migration that builds the index; multi-schema databases where the pool connects without setting search_path; index renamed or dropped by a concurrent migration.","solutions":["Confirm the index exists: query pg_indexes (schemaname, indexname) or \\di in psql for the exact name","Create the index first (bridge.createIndex) and only then fetch stats","For non-default schemas, use the schema-qualified name or set the pool's search_path so pg_stat_user_indexes can see it"],"exampleFix":"// before\nconst stats = await bridge.getIndexStats('idx_missing'); // throws\n\n// after\nawait bridge.createIndex({ tableName: 'vectors', columnName: 'embedding', indexType: 'hnsw' });\nconst stats = await bridge.getIndexStats('idx_vectors_embedding_hnsw');","handlingStrategy":"validation","validationCode":"const exists = await bridge.query(\n  `SELECT 1 FROM pg_indexes WHERE indexname = $1`,\n  [indexName]\n);\nif (exists.rows.length === 0) {\n  throw new Error(`Index '${indexName}' does not exist — create it before reading stats`);\n}\nconst stats = await bridge.getIndexStats(indexName);","typeGuard":null,"tryCatchPattern":"try {\n  return await bridge.getIndexStats(indexName);\n} catch (err) {\n  if (err instanceof Error && err.message.endsWith('not found')) {\n    return null; // treat missing index as 'no stats yet'\n  }\n  throw err;\n}","preventionTips":["Run createIndex migrations before maintenance jobs that poll stats","Use schema-qualified names or set search_path when the index lives outside public","Handle the not-found case gracefully in monitoring loops (index may be mid-rebuild with replace: true)"],"tags":["database","pgvector","index-management","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}