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

@ -3628,11 +3628,15 @@ export class S3CompatibleStorage extends BaseStorage {
const bodyContents = await response.Body.transformToString()
return JSON.parse(bodyContents)
} catch (error: any) {
if (
// S3 may return not found errors in different formats
const isNotFound =
error.name === 'NoSuchKey' ||
error.code === 'NoSuchKey' ||
error.$metadata?.httpStatusCode === 404 ||
error.message?.includes('NoSuchKey') ||
error.message?.includes('not found')
) {
error.message?.includes('not found') ||
error.message?.includes('404')
if (isNotFound) {
return null
}