Skip to content

.Net: Fixes Qdrant 1.17 issue with returning empty vectors#13638

Queued
TsengSR wants to merge 4 commits intomicrosoft:mainfrom
TsengSR:bugfix/qdrant-1.17
Queued

.Net: Fixes Qdrant 1.17 issue with returning empty vectors#13638
TsengSR wants to merge 4 commits intomicrosoft:mainfrom
TsengSR:bugfix/qdrant-1.17

Conversation

@TsengSR
Copy link
Contributor

@TsengSR TsengSR commented Mar 6, 2026

Motivation and Context

With Qdrant server 1.17 Embeddings stopped being returned.

Fixes #13587

Description

The VectorOutput.Data property became deprecated in Qdrant.Client 1.17. The alternative is to use VectorOutput.Dense.Data instead or VectorOutput.GetDenseVector() (from Qdrant.Client 1.16.0 or later).

Since the .Dense already exyists in Qdrant.Client 1.15.1 that is used by the current connector, I used these. The .GetDenseVector() also returns nullable DenseVector, so I was unsure how to handle in context of Semantic Kernel, as as far as I see it Semantic Kernel only supports Dense Vectors (the other two are .Sparse for sparse vectors and .MultiDense).

So this may need special handling in future to throw an exception, when the server returns one of the other two vector types and not dense vectors.

Contribution Checklist

I'm currently unable (or rather I don't know how) to run the local integration/unit tests against the qdrant database. But I validated the change in my personal project mentioned in #13587 by directly referencing the connector in my project and it correctly returned the vectors on the sample code where it failed previously

    VectorStoreCollection<ulong, VectorModels.Project> projects = await GetProjectsCollection();
    VectorModels.Project? project = await projects.GetAsync((ulong)projectId, new()
    {
        IncludeVectors = true
    });

    // project at this poind hat 0 sized Embedding property
    if (project is null)
    {
        return;
    }
    await projects.UpsertAsync(project);

@TsengSR TsengSR requested a review from a team as a code owner March 6, 2026 20:49
@moonbox3 moonbox3 added the .NET Issue or Pull requests regarding .NET code label Mar 6, 2026
@github-actions github-actions bot changed the title Fixes Qdrant 1.17 issue with returning empty vectors .Net: Fixes Qdrant 1.17 issue with returning empty vectors Mar 6, 2026
@westey-m
Copy link
Contributor

westey-m commented Mar 9, 2026

Thanks @TsengSR, seems like a straightforward enough change. The integration tests automatically spin up a qdrant container in docker to test against locally. So running the tests should do all the work, as long as you have docker installed.
They also run during the PR merge process, so we can check then if nothing has regressed.

Looks like a few of the unit tests need updating though to match the latest code.

@TsengSR
Copy link
Contributor Author

TsengSR commented Mar 9, 2026

Okay, seems the test can run (net472 fails, seems tls validation issue with the qdrant store), but there seems to be issues.

The containers spinning up during the tests are qdrant 1.13.4 (shows under the qdrant logo, when they spin up) which probably still only suports the old format. I had 1.16.3 previously and upgraded to 1.17 when it happened.

But all I could find is

await client.Images.CreateImageAsync(
new ImagesCreateParameters
{
FromImage = "qdrant/qdrant",
Tag = "latest",
},
null,
new Progress<JSONMessage>());

which should be 1.17.0, but its not what runs in the container. Any ideas/pointers?

@westey-m
Copy link
Contributor

westey-m commented Mar 9, 2026

@TsengSR, check out https://github.com/microsoft/semantic-kernel/blob/main/dotnet/test/VectorData/Qdrant.ConformanceTests/Support/QdrantTestStore.cs#L21.

We use https://testcontainers.com/modules/qdrant/?language=dotnet. I see we don't pass a version into QdrantBuilder, so I would have expected it to use the latest version, but I guess not. It's possible to pass a specific version though:

var qdrantContainer = new QdrantBuilder("qdrant/qdrant:v1.13.4")
  .Build();

The code you shared is actually samples, but the tests are all under https://github.com/microsoft/semantic-kernel/blob/main/dotnet/test/VectorData

Updated Testcontainers.Qdrant to be able to use the string constructor to set a qdrant image version
@TsengSR
Copy link
Contributor Author

TsengSR commented Mar 9, 2026

@TsengSR, check out https://github.com/microsoft/semantic-kernel/blob/main/dotnet/test/VectorData/Qdrant.ConformanceTests/Support/QdrantTestStore.cs#L21.

We use https://testcontainers.com/modules/qdrant/?language=dotnet. I see we don't pass a version into QdrantBuilder, so I would have expected it to use the latest version, but I guess not. It's possible to pass a specific version though:

var qdrantContainer = new QdrantBuilder("qdrant/qdrant:v1.13.4")
  .Build();

The code you shared is actually samples, but the tests are all under https://github.com/microsoft/semantic-kernel/blob/main/dotnet/test/VectorData

Thanks, that helped a lot. The current Testcontainers.Qdrant didn't had any constructor, updated to 4.10.0 locally which contain these (and deprecates the parameterless one). Its still odd ":latest" tag gave v1.16.3, but ":v1.17.0" pulled the correct image.

Had to change the setup slightly for Weaviate Tests, as UntilPortIsAvailable was removed, see comment.

Fixed the test issues by doing pattern matching whether .Dense is null or not and otherwise fall back to .Data. .Data will eventually be removed at some point in future as its deprecated from Qdrant.Client: 1.16.0 onwards, but for l left the Qdrant.Client at 1.15.1

update:
One thing I noticed is that QdrantUnitTests don't run against the database and something internally sets the VectorOutput.Data, so these tests were failing when not having the { Data: not null} => fall back. Didn't bother yet to look where that happens, but its something to consider when VectorOutput.Data gets removed eventually.

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but see the global.json change.

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@westey-m waiting for your approval now.

@roji
Copy link
Member

roji commented Mar 10, 2026

@TsengSR see build error in CI.

auto-merge was automatically disabled March 10, 2026 10:11

Head branch was pushed to by a user without write access

@TsengSR
Copy link
Contributor Author

TsengSR commented Mar 10, 2026

@TsengSR see build error in CI.

Fixed that. There are 4 tests failing on pinecone, but this also fail when I run them against main branch. Not sure its related to my machine setup. For qdrant net472 most fail too, but net10 they succeed. Hope it will work though.

image

@westey-m westey-m added this pull request to the merge queue Mar 10, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 10, 2026
@westey-m westey-m added this pull request to the merge queue Mar 10, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 10, 2026
@westey-m westey-m added this pull request to the merge queue Mar 11, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 11, 2026
@roji roji added this pull request to the merge queue Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.Net: Bug: Wrong input: Vector dimension error: expected dim: 3072, got 0 with qdrant server 1.17.0

4 participants