{"record":{"id":"b72c0eb6680ed271","repo":"FlowiseAI/Flowise","slug":"number-of-keys-keystrings-length-does-not-mat-b72c0e","errorCode":null,"errorMessage":"Number of keys (${keyStrings.length}) does not match number of group_ids (${groupIds.length})","messagePattern":"Number of keys \\((.+?)\\) does not match number of group_ids \\((.+?)\\)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/recordmanager/SQLiteRecordManager/SQLiteRecordManager.ts","lineNumber":262,"sourceCode":"        const queryRunner = dataSource.createQueryRunner()\n        const tableName = this.sanitizeTableName(this.tableName)\n\n        const updatedAt = await this.getTime()\n        const { timeAtLeast, groupIds: _groupIds } = updateOptions ?? {}\n\n        if (timeAtLeast && updatedAt < timeAtLeast) {\n            throw new Error(`Time sync issue with database ${updatedAt} < ${timeAtLeast}`)\n        }\n\n        // Handle both new format (objects with uid and docId) and old format (strings)\n        const isNewFormat = keys.length > 0 && typeof keys[0] === 'object' && 'uid' in keys[0]\n        const keyStrings = isNewFormat ? (keys as Array<{ uid: string; docId: string }>).map((k) => k.uid) : (keys as string[])\n        const docIds = isNewFormat ? (keys as Array<{ uid: string; docId: string }>).map((k) => k.docId) : keys.map(() => null)\n\n        const groupIds = _groupIds ?? keyStrings.map(() => null)\n\n        if (groupIds.length !== keyStrings.length) {\n            throw new Error(`Number of keys (${keyStrings.length}) does not match number of group_ids (${groupIds.length})`)\n        }\n\n        const recordsToUpsert = keyStrings.map((key, i) => [key, this.namespace, updatedAt, groupIds[i] ?? null, docIds[i] ?? null])\n\n        const query = `\n        INSERT INTO \"${tableName}\" (key, namespace, updated_at, group_id, doc_id)\n        VALUES (?, ?, ?, ?, ?)\n        ON CONFLICT (key, namespace) DO UPDATE SET updated_at = excluded.updated_at, doc_id = excluded.doc_id`\n\n        try {\n            // To handle multiple files upsert\n            for (const record of recordsToUpsert) {\n                // Consider using a transaction for batch operations\n                await queryRunner.manager.query(query, record.flat())\n            }\n            await queryRunner.release()\n        } catch (error) {\n            console.error('Error updating in SQLiteRecordManager:')","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/recordmanager/SQLiteRecordManager/SQLiteRecordManager.ts#L244-L280","documentation":"SQLite analog of errors 264/269. Thrown in SQLiteRecordManager.update when groupIds length differs from keyStrings length. SQLite uses the same per-key zip pattern, so a mismatch is rejected to prevent row misalignment.","triggerScenarios":"updateOptions.groupIds array with a different count than keys; partial filtering of keys downstream of groupIds; mixing key formats.","commonSituations":"Ingestion batch slicing keys but not groupIds; deduplication applied to one array only.","solutions":["Omit groupIds to default each to null.","Zip and filter keys+groupIds together at the source.","Validate lengths match before the call."],"exampleFix":"// before\nawait mgr.update(keys, { groupIds: groups })\n// after\nawait mgr.update(keys, { groupIds: keys.map((_, i) => groups[i] ?? null) })","handlingStrategy":"validation","validationCode":"function validateKeysAndGroupIds(keys: unknown[], groupIds?: unknown[]): void {\n  if (groupIds && groupIds.length !== keys.length) {\n    throw new Error(`groupIds (${groupIds.length}) must equal keys (${keys.length})`)\n  }\n}","typeGuard":"function areAligned(keys: unknown[], groupIds: unknown[] | undefined): boolean {\n  return !groupIds || groupIds.length === keys.length\n}","tryCatchPattern":"try {\n  await manager.update(keys, { groupIds })\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Number of keys')) {\n    // drop groupIds or realign upstream\n  }\n  throw e\n}","preventionTips":["Pair keys and groupIds at the source.","Default groupIds to undefined when unused.","Assert length equality in tests."],"tags":["sqlite","record-manager","validation","array-length","upsert"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}