Skip to content

.Net: Bug: [SqliteVectorStore] NOT NULL constraint failed: words.json during UpsertAsync #13476

@P47K0

Description

@P47K0

Describe the bug
Calling UpsertAsync (single or batch) on a SqliteVectorStore collection throws:

SQLite Error 19: 'NOT NULL constraint failed: words.json'

The json column in the words table (or collection-named table) is defined as NOT NULL, but the connector serializes the non-vector properties into a null or empty value, violating the constraint.

Even after:

  • GetCollection succeeds
  • Dummy upsert attempts (single record, non-zero vector, empty batch) fail with the same error

To Reproduce

[VectorStoreRecord]
public record HangmanWordRecord
{
    [VectorStoreRecordKey]
    public int Key { get; init; }

    [VectorStoreData]
    public string Word { get; init; } = string.Empty;

    [VectorStoreData]
    public string Category { get; init; } = string.Empty;

    [VectorStoreData]
    public string Language { get; init; } = string.Empty;

    [VectorStoreData]
    public int Length { get; init; }

    [VectorStoreRecordVector(Dimensions = 768)]
    public ReadOnlyMemory<float> Embedding { get; init; } = default;
}

var store = new SqliteVectorStore("Data Source=:memory:");
var collection = store.GetCollection<int, HangmanWordRecord>("words");

var record = new HangmanWordRecord
{
    Key = 1,
    Word = "apple",
    Category = "food",
    Language = "en",
    Length = 5,
    Embedding = new ReadOnlyMemory<float>(new float[768])
};

await collection.UpsertAsync(record);  // throws NOT NULL constraint failed: words.json

Expected behavior

  • UpsertAsync succeeds
  • json column contains serialized non-vector properties (or is nullable if empty)

Workarounds tried

  • Explicit non-empty string values in all [VectorStoreData] properties — still fails
  • Relaxed schema (json TEXT without NOT NULL) — insert succeeds, but json column remains null/empty
  • Manual raw SQL insert with JsonSerializer.Serialize — works reliably

Screenshots

Platform

  • Language: C#
  • .NET: 10.0
  • Source:
    • Semantic Kernel version: 1.70.0
    • Connector: Microsoft.SemanticKernel.Connectors.SqliteVec 1.70.0-preview
  • Database: SQLite (file-based)
  • vec0.dll ->0.1.7-alpha.2 (loadable extension from https://github.com/asg017/sqlite-vec/releases)
  • AI model: nomic-embed-text via ollama
  • IDE: Visual Studio 2026 Pro
  • OS: Winsows 11 x64
  • GPU: Intel Arc iGPU

Additional context

  • Occurs with both in-memory SQLite file-based DB
  • Same issue in SqliteVec connector (chunk tables also remain empty)
  • Manual SQL workaround bypasses the bug completely

You can see my simple Hangman game where I encountered the issue here:
https://github.com/P47K0/SKOrchestrationPractice

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codebugSomething isn't workingtriage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions