Skip to content

feat(storage): delete vectors by key from a vector index - #858

Merged
Tr00d merged 1 commit into
masterfrom
feat/storage.vector_buckets.delete_vectors
Nov 25, 2026
Merged

Tr00d merged 1 commit into
masterfrom
feat/storage.vector_buckets.delete_vectors

Conversation

@Tr00d

@Tr00d Tr00d commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Summary

A caller can delete vectors by key from a vector index: storage.Vectors.From(bucket).Index(name).DeleteVectorsAsync(keys). This is the first operation on IVectorIndex, so the index scope now carries its bucket name, index name and the vector transport.

Capability: storage.vector_buckets.delete_vectors, Delete Vectors. No capability spec exists for this group.

Public API

// IVectorIndex (Supabase.Storage.Interfaces)
[ImplementedCapability("storage.vector_buckets.delete_vectors")]
Task DeleteVectorsAsync(IReadOnlyCollection<string> keys, CancellationToken cancellationToken = default);

New public types: none.

await storage.Vectors.From("embeddings-prod").Index("docs-v1")
    .DeleteVectorsAsync(new[] { "doc-1", "doc-2" });

Behavior

  • Operation: POST {storage}/vector/DeleteVectors with body {"vectorBucketName","indexName","keys":[…]}. Requires a service-role key.
  • Inputs: keys is required. The bucket and index names come from the scope, which From and Index already check. The SDK fills in no defaults.
  • Checks before the wire: only a null keys (ArgumentNullException). The service judges an empty batch, empty keys, key length and the batch limit (validation belongs to the service). Whitespace keys are valid vector keys.
  • Output: none. The service answers 200 with an empty body. A key that matches no vector is ignored.
  • Failures (SupabaseStorageException):
    • 400 InvalidRequest: empty batch, empty key, too many keys.
    • 404 NotFoundException: the bucket or index is missing.
    • 403 → Reason.NotAuthorized: the caller is not the service role.
    • 404 route not found: the vector service is disabled (self-hosted).
    • 409 FeatureNotEnabled: the vector service is not configured.
    • 500: internal failure.
  • State: none.

Deviations from supabase-js

  • supabase-js throws when the batch is outside 1–500 keys. This SDK leaves the batch limit to the service, so a change to the limit reaches every SDK version on the same day.

Tests

Tier Class Pins
E2E VectorDeletionTests Only the named vectors are deleted; an unknown key is a no-op; a missing index gives 404 NotFoundException; an empty batch gives the service's 400 InvalidRequest. Run against the local stack's pgvector-backed vector service.
Contract DeleteVectorsContractTests Method, path, body and auth header; an empty collection is still sent; failure mapping (400/404/500, 403 → NotAuthorized, route not found); cancellation; dynamic headers
Contract DeleteVectorsApprovalTests Exact request bytes, matching the service's DeleteVectors schema
Unit DeleteVectorsTests A null keys throws ArgumentNullException before any I/O

Changed-line coverage: 100% (21 lines). Mutation: 5/5 on changed lines killed, 0 survivors (13/13 across the mutated files).

Notes

  • The local CLI stack serves the vector service by default (VECTOR_ENABLED=true, pgvector provider), so config.toml is unchanged. The E2E seeds the bucket and vectors, and checks the deletion, over plain HTTP (CreateVectorBucket, PutVectors, GetVectors), because those capabilities are not in the SDK yet. Each test uses a unique bucket name and tears it down.
  • The service's wire code for a missing vector resource is NotFoundException. Existing docs and tests on master use S3VectorNotFoundException / S3VectorBucketNotEmpty, which are the service's enum member names rather than its wire values. Fixing them is a separate follow-up.

@Tr00d
Tr00d marked this pull request as ready for review November 25, 2026 07:25
@Tr00d
Tr00d merged commit 094e7b4 into master Nov 25, 2026
7 checks passed
@Tr00d
Tr00d deleted the feat/storage.vector_buckets.delete_vectors branch November 25, 2026 07:28
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