{"record":{"id":"2f797ee49c7da341","repo":"ruvnet/ruflo","slug":"unsupported-index-type-options-indextype","errorCode":null,"errorMessage":"Unsupported index type: ${options.indexType}","messagePattern":"Unsupported index type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/plugins/src/integrations/ruvector/ruvector-bridge.ts","lineNumber":864,"sourceCode":"    const durationMs = Date.now() - startTime;\n    const deleted = result.affectedRows ?? 0;\n\n    return {\n      total: ids.length,\n      successful: deleted,\n      failed: ids.length - deleted,\n      durationMs,\n      throughput: deleted / (durationMs / 1000),\n    };\n  }\n\n  /**\n   * Create a vector index.\n   */\n  async createIndex(options: VectorIndexOptions): Promise<void> {\n    const indexType = INDEX_TYPE_SQL[options.indexType];\n    if (!indexType && options.indexType !== 'flat') {\n      throw new Error(`Unsupported index type: ${options.indexType}`);\n    }\n\n    const indexName = options.indexName ??\n      `idx_${options.tableName}_${options.columnName}_${options.indexType}`;\n    const schemaPrefix = this.config.schema ? `${this.escapeIdentifier(this.config.schema)}.` : '';\n\n    if (options.replace) {\n      await this.connectionManager.query(\n        `DROP INDEX IF EXISTS ${schemaPrefix}${this.escapeIdentifier(indexName)}`\n      );\n    }\n\n    if (options.indexType === 'flat') {\n      return; // No index needed for brute force\n    }\n\n    // Build operator class based on metric\n    const opClass = this.getOperatorClass(options.metric ?? 'cosine', options.indexType);","sourceCodeStart":846,"sourceCodeEnd":882,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/plugins/src/integrations/ruvector/ruvector-bridge.ts#L846-L882","documentation":"Thrown by createIndex() when options.indexType is not a key of INDEX_TYPE_SQL. Supported types are 'hnsw', 'ivfflat', 'ivfpq', 'flat', and 'diskann' (the last two being special-cased: flat skips index creation, diskann falls back to HNSW). Any other string yields undefined in the lookup and is rejected as unsupported.","triggerScenarios":"Passing 'ivf', 'lsh', 'HNSW' (wrong case), or a value read straight from user config into createIndex(); forwarding an indexType meant for a different vector DB (e.g. pgvector syntax like 'hnsw_cosine') verbatim.","commonSituations":"Porting configs from another vector store whose type names differ; config fields typed as plain string instead of the VectorIndexType union; casing drift after a config refactor.","solutions":["Use one of: 'hnsw', 'ivfflat', 'ivfpq', 'flat', 'diskann' (lowercase)","Type the field as the library's VectorIndexType union so invalid literals fail at compile time","Validate/normalize config-sourced values (trim + lowercase + allowlist) before calling createIndex"],"exampleFix":"// before\nawait bridge.createIndex({ tableName: 'vectors', columnName: 'embedding', indexType: 'HNSW' }); // throws\n\n// after\nawait bridge.createIndex({ tableName: 'vectors', columnName: 'embedding', indexType: 'hnsw' });","handlingStrategy":"type-guard","validationCode":"const INDEX_TYPES = ['hnsw', 'ivfflat', 'ivfpq', 'flat', 'diskann'] as const;\nconst indexType = String(cfg.indexType).trim().toLowerCase() as (typeof INDEX_TYPES)[number];\nif (!INDEX_TYPES.includes(indexType)) {\n  throw new Error(`indexType must be one of: ${INDEX_TYPES.join(', ')}`);\n}\nawait bridge.createIndex({ tableName, columnName, indexType });","typeGuard":"const isVectorIndexType = (t: unknown): t is 'hnsw' | 'ivfflat' | 'ivfpq' | 'flat' | 'diskann' =>\n  typeof t === 'string' &&\n  ['hnsw', 'ivfflat', 'ivfpq', 'flat', 'diskann'].includes(t);","tryCatchPattern":"try {\n  await bridge.createIndex(opts);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Unsupported index type')) {\n    throw new ConfigurationError(`${opts.indexType} is not a pgvector index type this bridge supports`);\n  }\n  throw err;\n}","preventionTips":["Type index config as the library's VectorIndexType union instead of string","Validate config-sourced indexType against the allowlist before calling createIndex","Remember 'flat' (no index) and 'diskann' (HNSW fallback) are legal but behave specially"],"tags":["database","pgvector","index-management","enum-validation"],"backgroundTag":"unsupported-type","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}