Repository navigation
Description
Description
A project scaffolded with dotnet new aichatweb --provider azureopenai (template Microsoft.Extensions.AI.Templates 10.9.0-preview.3.26411.16, default --vector-store local, which now maps to CommunityToolkit.VectorData.SqliteVec) throws on the first chat/search request:
System.InvalidOperationException: The collection's generic key type is 'String', but the key property 'Key' has type 'Guid'. The generic key type must match the key property type.
The generated code is internally inconsistent about the vector-store key type:
| Generated file | Key type used |
|---|---|
Services/IngestedChunk.cs |
public required Guid Key { get; set; } |
Program.cs |
builder.Services.AddSqliteCollection<string, IngestedChunk>(...) |
Services/SemanticSearch.cs |
VectorStoreCollection<string, IngestedChunk> |
Services/Ingestion/DataIngestor.cs |
new VectorStoreWriter<string>(...), new IngestionPipeline<string>(...) |
The record's [VectorStoreKey] property is Guid; everything that binds the collection uses string as TKey. SqliteVec validates that these match (SqliteModelBuilder.ValidateKeyProperty) and throws when building the model.
Reproduction Steps
Reproduce via the template
dotnet new install Microsoft.Extensions.AI.Templates::10.9.0-preview.3.26411.16dotnet new aichatweb --provider azureopenai -o ReproGuid- Set
AzureOpenAI:Endpoint+ chat/embedding deployment names, thendotnet run - Send any chat message. The exception is thrown from
SemanticSearchthe first
time the collection is resolved. (dotnet buildsucceeds — this is runtime only.)
Unhandled exception. System.InvalidOperationException: The collection's generic key type is 'String', but the key property 'Key' has type 'Guid'. The generic key type must match the key property type.
at Microsoft.Extensions.VectorData.ProviderServices.CollectionModelBuilder.ValidateKeyProperty(KeyPropertyModel keyProperty)
at CommunityToolkit.VectorData.SqliteVec.SqliteModelBuilder.ValidateKeyProperty(KeyPropertyModel keyProperty) in /home/runner/work/AI/AI/MEVD/src/SqliteVec/SqliteModelBuilder.cs:line 25
at Microsoft.Extensions.VectorData.ProviderServices.CollectionModelBuilder.ValidateProperty(PropertyModel propertyModel, VectorStoreCollectionDefinition definition)
at Microsoft.Extensions.VectorData.ProviderServices.CollectionModelBuilder.Validate(Type type, VectorStoreCollectionDefinition definition)
at Microsoft.Extensions.VectorData.ProviderServices.CollectionModelBuilder.Build(Type recordType, Type keyType, VectorStoreCollectionDefinition definition, IEmbeddingGenerator defaultEmbeddingGenerator)
at CommunityToolkit.VectorData.SqliteVec.SqliteCollection`2..ctor(...)
at CommunityToolkit.VectorData.SqliteVec.SqliteVectorStore.GetCollection[TKey,TRecord](String name, VectorStoreCollectionDefinition definition) in /home/runner/work/AI/AI/MEVD/src/SqliteVec/SqliteVectorStore.cs:line 69
at Program.<Main>$(String[] args)
Expected behavior
The scaffolded project builds and runs; document ingestion and semantic search work out of the box.
Actual behavior
InvalidOperationException the first time the IngestedChunk collection is built, because the [VectorStoreKey] property is Guid while the collection is bound with string as TKey.
Regression?
Appears to be fallout from the DataIngestion key-type migration from string to auto-generated Guid keys (#7410, #7396, #7557). Services/IngestedChunk.cs was updated to Guid Key, but Program.cs / SemanticSearch.cs / DataIngestor.cs and the pinned Microsoft.Extensions.DataIngestion version were not.
Known Workarounds
Make the key type consistent. The only variant that compiles against the pinned
package set is string — change IngestedChunk.Key back to string:
[VectorStoreKey(StorageName = "key")]
[JsonPropertyName("key")]
public required string Key { get; set; }Going the other way (AddSqliteCollection<Guid, IngestedChunk>, VectorStoreCollection<Guid, IngestedChunk>, VectorStoreWriter<Guid>, IngestionPipeline<Guid>) does not compile with Microsoft.Extensions.DataIngestion 10.9.0-preview.1.26411.16, because SemanticSimilarityChunker is IngestionChunker<string> there:
error CS1503: Argument 2: cannot convert from
'Microsoft.Extensions.DataIngestion.Chunkers.SemanticSimilarityChunker' to
'Microsoft.Extensions.DataIngestion.IngestionChunker<System.Guid>'
Configuration
- Template:
Microsoft.Extensions.AI.Templates10.9.0-preview.3.26411.16 - .NET SDK:
10.0.400 --provider azureopenai,--vector-store local(SqliteVec), no Aspire- Generated package references:
Microsoft.Extensions.AI/Microsoft.Extensions.AI.OpenAI10.9.0Microsoft.Extensions.DataIngestion/.Markdig10.9.0-preview.1.26411.16CommunityToolkit.VectorData.SqliteVec1.0.1-previewMicrosoft.Extensions.VectorData.Abstractions10.7.0(transitive)
- OS: macOS 12.7.6 (x64). Isolated repro is OS-independent.
Other information
dotnet build on the generated project succeeds; the failure is purely at runtime when the SqliteVec model is built (eagerly in GetCollection, or lazily via SemanticSearch in the template).
Activity