Skip to content

Validate sparse vector dictionary bounds - #65

Open
Mr444-dev wants to merge 1 commit into
pgvector:masterfrom
Mr444-dev:fix/sparsevector-index-bounds
Open

Mr444-dev wants to merge 1 commit into
pgvector:masterfrom
Mr444-dev:fix/sparsevector-index-bounds

Conversation

@Mr444-dev

Copy link
Copy Markdown

What changed

Validate that dimensions is non-negative and that each non-zero dictionary key is within [0, dimensions) when constructing a SparseVector.

Why

Previously, invalid indices produced a SparseVector that could fail later in ToArray() or serialize with invalid coordinates. The constructor now rejects invalid input at the point it is supplied.

Testing

dotnet test tests/Pgvector.CSharp.Tests/Pgvector.CSharp.Tests.csproj --no-restore --filter 'FullyQualifiedName~SparseVectorTests|FullyQualifiedName~VectorTests|FullyQualifiedName~HalfVectorTests' — 13 passed.

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