fix(hnsw): entry point recovery prevents import failures and log spam

Fixes critical production bug where HNSW index operations would fail
and spam thousands of console.error messages during large imports.

Root cause: rebuild() nullifies entryPointId via clear(), and if
getHNSWSystem() returns null (missing/corrupted system data), the
entry point was never recovered from loaded nouns.

Changes:
- Add entry point recovery in rebuild() after loading nouns
- Add entry point recovery in search() for corrupted state
- Add entry point recovery in search() when entry point noun deleted
- Remove console.error spam in search() and addItem()
- Standardize 404 error detection in GCS/S3/Azure storage adapters

Tested: All entry point scenarios now recover gracefully without
log spam. Empty index returns empty results silently.
This commit is contained in:
David Snelling 2025-11-25 14:34:19 -08:00
parent 0c90eaa8cf
commit 52eae67cb8
4 changed files with 126 additions and 13 deletions

View file

@ -1567,7 +1567,15 @@ export class GcsStorage extends BaseStorage {
return JSON.parse(contents.toString())
} catch (error: any) {
if (error.code === 404) {
// GCS may return 404 in different formats depending on SDK version
const is404 =
error.code === 404 ||
error.statusCode === 404 ||
error.status === 404 ||
error.message?.includes('No such object') ||
error.message?.includes('not found') ||
error.message?.includes('404')
if (is404) {
return null
}