Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: metadata deserialization/type issue in GetResult struct #25

Merged

Conversation

ishaksebsib
Copy link
Contributor

This PR fixes Incorrect Metadata Deserialization in Rust Client (GetResult Struct) #24.

Issue:

The GetResult struct expected:

pub metadatas: Option<Vec<Option<Vec<Option<Metadata>>>>>,

But the API returns:

pub metadatas: Option<Vec<Option<Metadata>>>,

This mismatch caused a deserialization error:

error decoding response body: invalid type: map, expected a sequence at line 1 column 3571

Fix:

  • Changed metadatas type in GetResult to correctly match the API response.
  • Added test case test_get_all_metadatas_from_collection to verify fetching metadata from a collection.

Example from Chroma Docs:

metadatas: [{ "key": "value" }, { "key": "value" }]

Result:

With this fix, the Rust client now correctly deserializes metadata, allowing users to get collection data along with metadata without encountering errors.

Example Usage:

Here’s how to fetch collection data with metadata:

let get_query = GetOptions {
    ids: vec![],
    where_metadata: None,
    limit: None,
    offset: None,
    where_document: None,
    include: Some(vec!["metadatas".into()]),
};

let get_result = collection.get(get_query).await.unwrap();

This example shows how to get data from a collection, including metadata, without any deserialization issues.

Copy link
Owner

@Anush008 Anush008 left a comment

Choose a reason for hiding this comment

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

Thank you @ishaksebsib. LGTM!

@Anush008 Anush008 changed the title Fix metadata deserialization/type issue in GetResult struct fix: metadata deserialization/type issue in GetResult struct Mar 4, 2025
@Anush008 Anush008 merged commit 5c137ac into Anush008:master Mar 4, 2025
1 check passed
@Anush008 Anush008 linked an issue Mar 4, 2025 that may be closed by this pull request
github-actions bot pushed a commit that referenced this pull request Mar 4, 2025
## [2.2.2](v2.2.1...v2.2.2) (2025-03-04)

### Bug Fixes

* metadata deserialization/type issue in GetResult struct ([#25](#25)) ([5c137ac](5c137ac))

## [2.2.2](v2.2.1...v2.2.2) (2025-03-04)

### 🐛 Bug Fixes

* metadata deserialization/type issue in GetResult struct ([#25](#25)) ([5c137ac](5c137ac))
Copy link

github-actions bot commented Mar 4, 2025

🎉 This PR is included in version 2.2.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect Metadata Deserialization in Rust Client (GetResult Struct)
2 participants