From ae91e834f479bfbe6e796766af8ce40341549738 Mon Sep 17 00:00:00 2001 From: Maxwell Calkin <101308415+MaxwellCalkin@users.noreply.github.com> Date: Sun, 8 Mar 2026 07:23:54 -0400 Subject: [PATCH] fix: filter None values from IndexEmbed.as_dict() before creating CreateIndexForModelRequestEmbed When IndexEmbed is created with only required fields (model, field_map), as_dict() returns all attributes including metric=None. Passing this dict to CreateIndexForModelRequestEmbed(**parsed_embed) causes OpenAPI validation to reject None for the metric field (expects str). Filter out None values so only explicitly set fields are forwarded. Fixes #497 --- pinecone/db_control/request_factory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pinecone/db_control/request_factory.py b/pinecone/db_control/request_factory.py index 9c48524d..3eaf7b6a 100644 --- a/pinecone/db_control/request_factory.py +++ b/pinecone/db_control/request_factory.py @@ -435,7 +435,7 @@ def create_index_for_model_request( tags_obj = PineconeDBControlRequestFactory.__parse_tags(tags) if isinstance(embed, IndexEmbed): - parsed_embed = embed.as_dict() + parsed_embed = {k: v for k, v in embed.as_dict().items() if v is not None} else: # if dict, we need to parse enum values, if any, to string # and verify required fields are present