diff --git a/core/indexing/LanceDbIndex.ts b/core/indexing/LanceDbIndex.ts index a7012ca9e..264241ad2 100644 --- a/core/indexing/LanceDbIndex.ts +++ b/core/indexing/LanceDbIndex.ts @@ -286,11 +286,17 @@ export class LanceDbIndex implements CodebaseIndex { }; }); - if (needToCreateTable && lanceRows.length > 0) { - table = await db.createTable(tableName, lanceRows); - needToCreateTable = false; - } else if (lanceRows.length > 0) { - await table?.add(lanceRows); + if (lanceRows.length > 0) { + if (needToCreateTable) { + table = await db.createTable(tableName, lanceRows); + needToCreateTable = false; + } else if (!table) { + table = await db.openTable(tableName); + needToCreateTable = false; + await table.add(lanceRows); + } else { + await table?.add(lanceRows); + } } markComplete([{ path, cacheKey }], IndexResultType.AddTag); diff --git a/core/indexing/indexCodebase.ts b/core/indexing/indexCodebase.ts index e051dc001..dd9aad332 100644 --- a/core/indexing/indexCodebase.ts +++ b/core/indexing/indexCodebase.ts @@ -56,11 +56,11 @@ export class CodebaseIndexer { yield { progress: 0, desc: "Nothing to index", - status: "disabled", + status: "disabled", }; return; } - + const config = await this.configHandler.loadConfig(); if (config.disableIndexing) { yield { @@ -160,16 +160,28 @@ export class CodebaseIndexer { desc: "Completed indexing " + codebaseIndex.artifactId, status: "indexing", }; - } catch (e) { - yield { - progress: 0, - desc: `${e}`, - status: "failed" + } catch (e: any) { + let errMsg = `${e}`; + + const errorRegex = + /Invalid argument error: Values length (\d+) is less than the length \((\d+)\) multiplied by the value size \(\d+\)/; + const match = e.message.match(errorRegex); + + if (match) { + const [_, valuesLength, expectedLength] = match; + errMsg = `Generated embedding had length ${valuesLength} but was expected to be ${expectedLength}. This may be solved by deleting ~/.continue/index and refreshing the window to re-index.`; } + + yield { + progress: 0, + desc: errMsg, + status: "failed", + }; + console.warn( `Error updating the ${codebaseIndex.artifactId} index: ${e}`, ); - return + return; } }