microsoft / microsoft/semantic-kernel

.Net: Bug: .NET: RedisJsonCollection JSON upsert includes unannotated POCO properties

Open
#14,021 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

.NET bug triage
Dominant language
C#
Stars
28.6k
Forks
4.8k
Avg merge
14h 13m
Merged PRs (30d)
18

Description

Description

RedisJsonCollection<TKey, TRecord> currently includes unannotated public POCO properties when writing Redis JSON payloads during upsert.

RedisJsonMapper<T> serializes the whole record with JsonSerializer.SerializeToNode(...), removes only the key property, then adjusts vector fields. This means public properties that are not part of the vector-store model still get persisted into the Redis JSON payload.

I noticed the current Redis JSON unit tests already contain TODOs for this behavior:

// TODO: Fix issue where NotAnnotated is being included in the JSON.

The current expected JSON.SET / JSON.MSET payloads include the unannotated property, for example:

{"data1_json_name":"data 1","Data2":"data 2","vector1_json_name":[1,2,3,4],"Vector2":[1,2,3,4],"NotAnnotated":null}
Why I am opening this

I wanted to check whether this is intended behavior or a known issue that still needs tracking.

The Redis JSON connector documentation currently says JSON storage serializes all properties except the key, but the local test TODO suggests this may not be the desired final behavior for vector-store model mapping.

Repro

From a clean checkout:

$dotnet = Join-Path $env:TEMP 'dotnet-10-sdk\dotnet.exe'
& $dotnet test dotnet\test\VectorData\Redis.UnitTests\Redis.UnitTests.csproj --filter "FullyQualifiedName~RedisJsonCollectionTests.CanUpsertRecordAsync" --verbosity normal

The test passes because the expected Redis JSON payload currently includes the unannotated property.

Current behavior

Unannotated public POCO properties are persisted into Redis JSON payloads.

Expected behavior, if the TODO reflects intended behavior

Redis JSON upsert should only persist the vector-store model fields:

  • key used as the Redis key, not included in the payload
  • [VectorStoreData] properties
  • [VectorStoreVector] properties

Unannotated public properties should not be included.

Environment

Repo commit: 2fb749e4b
SDK used for local test run: .NET 10.0.300
OS: Windows 10 x64

Possible fix direction

If the intended behavior is to exclude unannotated properties, RedisJsonMapper<T> could build the JSON object from model.DataProperties and model.VectorProperties, similar to the dynamic mapper path, instead of serializing the full POCO and removing only the key.

If the current behavior is intended for Redis JSON mode, then the TODO in the tests may just need to be removed or clarified.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with RedisJsonMapper and the RedisJsonCollectionTests.CanUpsertRecordAsync test in dotnet/test/VectorData/Redis.UnitTests/Redis.UnitTests.csproj. Compare the mapper behavior with the test TODOs and the expected JSON.SET/JSON.MSET payloads. Done means the intended handling of unannotated properties is established and the focused test reflects the resulting payload.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, redis
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.