Skip to content

fix(storage): return vector input validation errors instead of throwing - #2782

Open
prestonschlagheck wants to merge 1 commit into
supabase:masterfrom
prestonschlagheck:fix/storage-vectors-validation-error-response
Open

prestonschlagheck wants to merge 1 commit into
supabase:masterfrom
prestonschlagheck:fix/storage-vectors-validation-error-response

Conversation

@prestonschlagheck

@prestonschlagheck prestonschlagheck commented Oct 21, 2026 •

Copy link
Copy Markdown

🔍 Description

What changed?

putVectors, deleteVectors and listVectors now run their input checks inside handleOperation. The checks are the 1–500 batch size and the segmentCount/segmentIndex ranges. A failed check now throws StorageError with the 'vectors' namespace instead of a plain Error.

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 plain Error, even when throwOnError() was not set:

const { data, error } = await index.putVectors({ vectors: [] })
// before: throws Error('Vector batch size must be between 1 and 500 items')
// after:  data === null, error is a StorageVectorsError with that message

The thrown value also wasn't a StorageError, so isStorageVectorsError(e) returned false for it.

After this change:

  • By default, the methods resolve with { data: null, error }.
  • With .throwOnError(), they still reject, now with a StorageVectorsError.
  • No request is sent when validation fails, same as before.

🔄 Breaking changes

  • This PR contains no breaking changes

Code that wrapped these calls in try/catch for the validation case now gets the error in error, which is the documented contract. The messages are unchanged.

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • I have run pnpm nx format to ensure consistent code formatting
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (if applicable) — n/a

📝 Additional notes

New test/vector-data-api-validation.test.ts has 10 cases: each invalid input, once in the default mode and once with throwOnError(). Each case asserts the error type and message, and that fetch is never called. All 10 fail on master.

@prestonschlagheck
prestonschlagheck requested review from a team as code owners October 21, 2026 18:45
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b075d57a-7163-42d9-94ec-e4a0616d6360
📥 Commits

Reviewing files that changed from the base of the PR and between f0feeaf and 59c080f.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a3f71d37-5a35-4956-878d-a43f6070da91
📥 Commits

Reviewing files that changed from the base of the PR and between 5adfffe and f0feeaf.

📒 Files selected for processing: 2
  • packages/core/storage-js/src/packages/VectorDataApi.ts
  • packages/core/storage-js/test/vector-data-api-validation.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for vector data operations.
    • Invalid vector batches, key batches, and listing segments now return structured storage errors with clearer messages.
    • Invalid requests are rejected before any network request is made.

putVectors, listVectors, and deleteVectors now validate inputs inside handleOperation. Validation failures use StorageError with the vectors service identifier. The batch-size and segment constraints remain unchanged. New tests cover invalid inputs, error results, thrown errors, and requests that do not call fetch.

Priority: ⚪ Pending latest changes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to f0fee

No confirmed issue blocks merging; the new validation tests can run without a prebuilt package artifact.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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().
@prestonschlagheck
prestonschlagheck force-pushed the fix/storage-vectors-validation-error-response branch from f0feeaf to 59c080f Compare October 21, 2026 18:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant