Repository navigation
fix(storage): return vector input validation errors instead of throwing - #2782
prestonschlagheck wants to merge 1 commit into
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Priority: ⚪ Pending latest changes Change: Bug fix Merge Risk: ⚪ Minimal · up to
|
putVectors, deleteVectors and listVectors validated batch sizes and segment
options before entering handleOperation and threw a plain Error. Callers that
follow the documented `{ data, error }` contract got a rejected promise
instead, and the error was not a StorageError, so isStorageVectorsError()
returned false.
Run the checks inside handleOperation and throw StorageError with the
'vectors' namespace, so the methods resolve with `{ data: null, error }` by
default and still reject under throwOnError().
f0feeaf to
59c080f
Compare
🔍 Description
What changed?
putVectors,deleteVectorsandlistVectorsnow run their input checks insidehandleOperation. The checks are the 1–500 batch size and thesegmentCount/segmentIndexranges. A failed check now throwsStorageErrorwith the'vectors'namespace instead of a plainError.Why was this change needed?
These methods are documented to resolve with "empty response on success or error", like every other storage method. But the checks ran before
handleOperation, so invalid input rejected the promise with a plainError, even whenthrowOnError()was not set:The thrown value also wasn't a
StorageError, soisStorageVectorsError(e)returnedfalsefor it.After this change:
{ data: null, error }..throwOnError(), they still reject, now with aStorageVectorsError.🔄 Breaking changes
Code that wrapped these calls in
try/catchfor the validation case now gets the error inerror, which is the documented contract. The messages are unchanged.📋 Checklist
<type>(<scope>): <description>pnpm nx formatto ensure consistent code formatting📝 Additional notes
New
test/vector-data-api-validation.test.tshas 10 cases: each invalid input, once in the default mode and once withthrowOnError(). Each case asserts the error type and message, and thatfetchis never called. All 10 fail onmaster.