← All work

Testing · mastra-ai/mastra

Test shared vector validation contracts in Mastra core

Adds a Vitest suite for four shared vector validation helpers. The tests cover input structure, numeric validity, MastraError contracts, and the optional value-checking behavior of validateUpsert.

The problem

The shared validation layer used by vector stores lacked unit coverage for these helpers. Its contracts include rejecting mismatched vector, metadata, and ID lengths, invalid topK values, and invalid vector components while preserving diagnostic error details.

The approach

Adds packages/core/src/vector/validation.test.ts with valid-input and error-path tests for validateUpsertInput, validateTopK, validateVectorValues, and validateUpsert. Assertions check MastraError fields and identifiers, plus vector and component indices in error messages. Combinator tests verify that validateUpsert checks structure and only validates component values when validateValues is enabled.

What changed

Introduces an additive test suite that exercises validation behavior and error contracts without changing runtime behavior or adding dependencies.

  • typescript
  • vitest
  • vector-stores
  • validation
  • unit-tests
  • error-handling