fix(sdk-116): resolve OpenAPI model breaking changes after regeneration#607
fix(sdk-116): resolve OpenAPI model breaking changes after regeneration#607
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|
✅ Issue 1 addressed: Removed the deprecated See commit: dcc3b36 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| starting_tags = {} | ||
| else: | ||
| starting_tags = fetched_tags.to_dict() | ||
| starting_tags = fetched_tags.to_dict() if hasattr(fetched_tags, "to_dict") else {} |
There was a problem hiding this comment.
Tags silently lost when fetched_tags lacks to_dict method
Medium Severity
The fallback to empty dict when fetched_tags doesn't have a to_dict() method could silently lose existing tags. If fetched_tags is a dict-like object without to_dict(), the code returns {} instead of using the dict directly. A safer approach would be to check isinstance(fetched_tags, dict) and use it directly in that case, rather than silently discarding the data.


Problem
After merging a series of AI-generated PRs that regenerated OpenAPI client models, the
ftsbranch was in a broken state with multiple critical issues:ConfigureIndexRequestEmbedmodule prevented the SDK from importingBackupModelSchema→Schema,BackupModelSchemaFields→SchemaFields,PodSpecMetadataConfig→PodDeploymentMetadataConfigIndexModelconstructor now requiresschemaanddeploymentas mandatory positional arguments (previously acceptedspec,dimension,metric)Solution
This PR systematically resolves all breaking changes introduced by the OpenAPI regeneration:
Architecture Changes
Request Factory Updates (
request_factory.py):ConfigureIndexRequestEmbedimport andembedparameter handling_translate_legacy_requestto properly instantiate OpenAPI Deployment models with discriminatorscreate_index_requestto convert dict representations to proper Deployment and Schema objectsReadCapacityDedicatedSpecnow hasscalingas an object withstrategy/replicas/shards)Backward Compatibility Layer (
tests/fixtures.py):make_index_model()helper that accepts both old-style (spec,dimension,metric) and new-style (deployment,schema) parametersTest Updates:
req.schema.fields["_values"].dimensioninstead ofreq.dimensiondeployment/schemastructurepods=1to all PodSpec instantiations (now required by validation)Key Technical Decisions
Deploymentunion class which automatically dispatches to the correct subclass (ServerlessDeployment,PodDeployment,ByocDeployment) based ondeployment_typefieldpods,replicas,shardscan be None in legacy code but must be integers in new API - use fallback defaults (1for replicas/shards, omit pods if None)Breaking Changes
None - All changes are internal implementation fixes. The public API remains backward compatible thanks to the IndexModel wrapper class which provides compatibility shims for
.dimension,.metric,.spec,.vector_typeproperties.Test Results
Before:
After:
Example Usage
Users don't need to change their code - the backward compatibility layer handles the translation:
Follow-up Items
spec/dimension/metricAPI in next major versionRelated Issues
Files Changed
Core implementation:
pinecone/db_control/request_factory.py- Fixed imports, model instantiation, and legacy parameter translationpinecone/db_control/resources/{sync,asyncio}/index.py- Removed obsolete importsTest infrastructure:
tests/fixtures.py- New backward compatibility helpertests/unit/db_control/test_index_request_factory.py- Updated assertions for new APItests/unit/test_control.py- Updated test fixturestests/unit/db_control/test_index.py- Fixed mock responsestests/unit/models/test_index_list.py- Updated to use compatibility helpertests/unit/openapi_support/test_api_client.py- Updated serialization testsMade with Cursor
Note
Medium Risk
Touches core index create/configure request translation and read-capacity parsing; regressions could cause malformed control-plane requests despite extensive test updates.
Overview
Aligns control-plane index creation with regenerated OpenAPI models by translating legacy
spec/dimension/metricinputs intodeployment+schemaobjects and by deserializing deployments via the OpenAPIDeploymentdiscriminator.Updates parsing for renamed/reshaped models (
BackupModelSchema*→Schema*,Pod*MetadataConfig→PodDeploymentMetadataConfig) and adjusts Dedicated read capacity to the new flattenednode_type+scaling{strategy,shards,replicas}structure.Removes now-missing embed configuration from
configure_indexrequests, hardens sync/async polling against status shape changes, and refreshes tests (newtests/fixtures.pyhelper plus updated mock responses/assertions, includingpodsrequirements for pod specs).Written by Cursor Bugbot for commit dcc3b36. This will update automatically on new commits. Configure here.