Describe the bug
InMemoryCollection.upsert() raises VectorStoreOperationException when a dictionary or dataclass record's key field has a storage_name different from its Python field name.
The record serializer produces the storage name, but _inner_upsert() still indexes the serialized record using the Python name.
To reproduce
import asyncio
from semantic_kernel.connectors.in_memory import InMemoryCollection
from semantic_kernel.data.vector import VectorStoreCollectionDefinition, VectorStoreField
async def main():
definition = VectorStoreCollectionDefinition(fields=[
VectorStoreField("key", name="id", type="str", storage_name="stored_id"),
VectorStoreField("vector", name="vector", type="float", dimensions=2),
])
collection = InMemoryCollection(collection_name="example", record_type=dict, definition=definition)
print(await collection.upsert({"id": "first", "vector": [1.0, 0.0]}))
asyncio.run(main())
On main at dcb969fbe624dc4efa462c2079831690425b98fd, this raises Error upserting record(s) into collection 'example': 'id'.
Expected behavior
The upsert returns "first", and the record can be retrieved or deleted using that key. Existing Pydantic records that serialize the Python field name should continue to work.
Platform
Python 3.12.2, Windows; Semantic Kernel Python source at the commit above.
Additional context
I can submit a small fix that reads the serialized storage key while preserving the existing logical-key serialization path, with dictionary, dataclass and Pydantic regression tests.
Describe the bug
InMemoryCollection.upsert()raisesVectorStoreOperationExceptionwhen a dictionary or dataclass record's key field has astorage_namedifferent from its Python field name.The record serializer produces the storage name, but
_inner_upsert()still indexes the serialized record using the Python name.To reproduce
On main at
dcb969fbe624dc4efa462c2079831690425b98fd, this raisesError upserting record(s) into collection 'example': 'id'.Expected behavior
The upsert returns
"first", and the record can be retrieved or deleted using that key. Existing Pydantic records that serialize the Python field name should continue to work.Platform
Python 3.12.2, Windows; Semantic Kernel Python source at the commit above.
Additional context
I can submit a small fix that reads the serialized storage key while preserving the existing logical-key serialization path, with dictionary, dataclass and Pydantic regression tests.