Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/core/storage-js/src/lib/common/BaseApiClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ErrorNamespace, isStorageError, StorageError } from './errors'
import { ErrorNamespace, isStorageError, StorageError, StorageUnknownError } from './errors'
import { Fetch } from './fetch'
import { normalizeHeaders, setHeader as setHeaderUtil } from './headers'
import { resolveFetch } from './helpers'
Expand Down Expand Up @@ -98,7 +98,10 @@ export default abstract class BaseApiClient<TError extends StorageError = Storag
if (isStorageError(error)) {
return { data: null, error: error as TError }
}
throw error
return {
data: null,
error: new StorageUnknownError(_getErrorMessage(error), error) as unknown as TError,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Do not let message extraction escape the error handler.

_getErrorMessage falls back to JSON.stringify, which throws for values containing circular references or bigint. Because it runs inside this catch, such inputs are re-thrown instead of returning the documented { data: null, error } tuple. Guard the extraction with a fallback message, or make _getErrorMessage total for arbitrary thrown values.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/storage-js/src/lib/common/BaseApiClient.ts` at line 103, Update
the error handling around _getErrorMessage in BaseApiClient so extracting a
message cannot throw for arbitrary values, including circular references or
bigint; ensure the catch always returns the documented { data: null, error }
tuple by using a safe fallback message, either locally or by making
_getErrorMessage total.

}
Comment on lines +101 to +104

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve the client error namespace.

BaseApiClient supports the vectors namespace, but this constructor call uses StorageUnknownError’s default 'storage' namespace. Vector clients will therefore receive the wrong error name/type. Pass this.namespace as the third constructor argument.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/storage-js/src/lib/common/BaseApiClient.ts` around lines 101 -
104, Update the error construction in BaseApiClient to pass this.namespace as
the third argument to StorageUnknownError, preserving the configured vectors or
storage namespace while leaving the existing message and cause unchanged.

}
}
}