Skip to content

WHIZ802: VectorField Invalid Dimensions

Severity: Error Category: Physical Field Validation

Description

This error occurs when a [VectorField] attribute is applied with an invalid dimensions value. The dimensions parameter must be a positive integer representing the number of elements in the vector.

Updated

As shipped, the WHIZ802 descriptor is defined in DiagnosticDescriptors.cs but the compile-time dimensions check is not yet wired into the schema generator. An invalid dimensions value currently surfaces when the generated DDL is applied: the generator emits the value verbatim into the column type (e.g. vector(0)), which PostgreSQL rejects because pgvector requires dimensions greater than zero. Fix the attribute value as shown below either way.

Diagnostic Message

[VectorField] on ProductDto.Embedding has invalid dimensions -1. Dimensions must be a positive integer.

Common Causes

  1. Zero dimensions - Using [VectorField(0)]
  2. Negative dimensions - Using [VectorField(-1)]
  3. Typo in dimensions - Accidentally typing wrong number

How to Fix

Specify a valid positive integer for the dimensions:

Before (causes WHIZ802)

Before (causes WHIZ802)

public record ProductDto {
  [StreamId]
  public Guid ProductId { get; init; }
  public string Name { get; init; } = string.Empty;

  [VectorField(0)]  // WHIZ802: Invalid dimensions
  public float[]? Embedding { get; init; }
}

After (error resolved)

After (error resolved)

public record ProductDto {
  [StreamId]
  public Guid ProductId { get; init; }
  public string Name { get; init; } = string.Empty;

  [VectorField(1536)]  // Valid - matches embedding model output
  public float[]? Embedding { get; init; }
}

Common Embedding Dimensions

Different embedding models produce vectors of specific dimensions:

Model Dimensions
OpenAI text-embedding-3-small 1536
OpenAI text-embedding-3-large 3072
OpenAI text-embedding-ada-002 1536
Cohere embed-english-v3 1024
Sentence Transformers (all-MiniLM-L6-v2) 384

Why Dimensions Matter

The dimensions parameter:

  1. Creates PostgreSQL column - vector(1536) type with fixed size
  2. Enables similarity search - pgvector uses dimensions for indexing
  3. Validates at insert - PostgreSQL rejects vectors with wrong dimensions

Example: Multiple Embedding Types

Example: Multiple Embedding Types

public record DocumentDto {
  [StreamId]
  public Guid DocumentId { get; init; }
  public string Title { get; init; } = string.Empty;

  [VectorField(1536)]  // OpenAI embeddings
  public float[]? ContentEmbedding { get; init; }

  [VectorField(384)]   // Sentence transformer for summaries
  public float[]? SummaryEmbedding { get; init; }
}

Suppressing This Diagnostic

This is an error diagnostic and should not be suppressed. Fix the dimensions value instead.

If you have a legitimate need:

Suppressing This Diagnostic

#pragma warning disable WHIZ802
[VectorField(0)]  // Not recommended
public float[]? TestEmbedding { get; init; }
#pragma warning restore WHIZ802
  • WHIZ070 - Missing Pgvector.EntityFrameworkCore package
  • WHIZ801 - VectorField on invalid type (must be float[])
  • WHIZ807 - Physical fields discovered (info)

See Also