{"record":{"id":"3b6e0a27e942a52b","repo":"ruvnet/ruflo","slug":"unknown-quantization-type-type","errorCode":null,"errorMessage":"Unknown quantization type: ${type}","messagePattern":"Unknown quantization type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/plugins/src/integrations/ruvector/quantization.ts","lineNumber":1344,"sourceCode":"      case 'scalar':\n        vectorColumn = `quantized_vector BYTEA NOT NULL`;\n        comment = `Scalar quantized vectors (int8, ${dimensions} dims, 4x compression)`;\n        break;\n\n      case 'binary':\n        const binaryBytes = Math.ceil(dimensions / 8);\n        vectorColumn = `binary_vector BIT(${dimensions})`;\n        comment = `Binary quantized vectors (${dimensions} dims, ${binaryBytes} bytes, 32x compression)`;\n        break;\n\n      case 'pq':\n      case 'opq':\n        vectorColumn = `pq_codes BYTEA NOT NULL`;\n        comment = `${type === 'opq' ? 'Optimized ' : ''}Product quantized vectors (M=${numSubvectors}, K=256)`;\n        break;\n\n      default:\n        throw new Error(`Unknown quantization type: ${type}`);\n    }\n\n    const extraCols = additionalColumns ? `\\n  ${additionalColumns},` : '';\n\n    return `\n-- Table for ${comment}\nCREATE TABLE IF NOT EXISTS ${tableName} (\n  id ${idType} PRIMARY KEY,${extraCols}\n  original_vector vector(${dimensions}),  -- Optional: keep original for reranking\n  ${vectorColumn},\n  metadata JSONB,\n  created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP\n);\n\n-- Index for quantized search\nCREATE INDEX IF NOT EXISTS idx_${tableName}_quantized ON ${tableName} (quantized_vector);\n\nCOMMENT ON TABLE ${tableName} IS '${comment}';","sourceCodeStart":1326,"sourceCodeEnd":1362,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/plugins/src/integrations/ruvector/quantization.ts#L1326-L1362","documentation":"Thrown by the SQL DDL generator (QuantizationSQL CREATE TABLE path) when the quantization `type` argument is not one of the supported literals 'scalar' | 'binary' | 'pq' | 'opq'. The switch has no other branches, so any other string (typo, casing, or an unvalidated config value) hits the default case.","triggerScenarios":"Passing 'int8' or 'sq' instead of 'scalar', 'PQ'/'OPQ' in uppercase, or forwarding a raw string from user config/env into the SQL generator without normalizing it.","commonSituations":"Config files copied from a different tool that names scalar quantization 'int8'; new team members guessing the enum; REST endpoint accepting a free-form type field that reaches this function unchecked.","solutions":["Use exactly one of: 'scalar', 'binary', 'pq', 'opq' (lowercase)","Normalize/validate the type at the config boundary: lowercase it and assert membership in the allowed set before generating DDL","Type the parameter as the library's union type so TypeScript rejects invalid literals at compile time"],"exampleFix":"// before\nconst ddl = sqlGen.generateCreateTableSQL('vectors', 'embedding', 128, 'int8'); // throws\n\n// after\nconst ddl = sqlGen.generateCreateTableSQL('vectors', 'embedding', 128, 'scalar');","handlingStrategy":"type-guard","validationCode":"const QUANTIZATION_TYPES = ['scalar', 'binary', 'pq', 'opq'] as const;\nconst type = String(rawType).trim().toLowerCase() as (typeof QUANTIZATION_TYPES)[number];\nif (!QUANTIZATION_TYPES.includes(type)) {\n  throw new Error(`type must be one of ${QUANTIZATION_TYPES.join(', ')}`);\n}\nconst ddl = sqlGen.generateCreateTableSQL(table, column, dims, type);","typeGuard":"const isQuantizationType = (t: string): t is 'scalar' | 'binary' | 'pq' | 'opq' =>\n  ['scalar', 'binary', 'pq', 'opq'].includes(t);","tryCatchPattern":"try {\n  ddl = generateCreateTableSQL(table, column, dims, type);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Unknown quantization type')) {\n    throw new ConfigurationError(`quantization.type '${type}' unsupported; use scalar|binary|pq|opq`);\n  }\n  throw err;\n}","preventionTips":["Type config fields with the library's union (or a local literal union), not string","Validate user/config input at the boundary with an allowlist and a helpful message","Keep a single constants module listing supported quantization types for both validation and DDL generation"],"tags":["quantization","sql-generation","invalid-argument","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-14T00:17:10.932Z"}