Skip to content

Prevent _get_api_instance from modifying OpenAPI config - #221

Merged
austin-denoble merged 1 commit into
mainfrom
adenoble/fix-custom-host
Oct 17, 2023
Merged

austin-denoble merged 1 commit into
mainfrom
adenoble/fix-custom-host

Conversation

@austin-denoble

Copy link
Copy Markdown
Member

Problem

Previous revision we added some code to apply a custom host value to control plane operations: #218

This change caused 404s when calling dataplane operations. The Configuration._base_path value was being overwritten by the custom host that was provided due to the Configuration.host setter:

  @host.setter
  def host(self, value):
      """Fix base path."""
      self._base_path = value
      self.server_index = None

https://github.com/pinecone-io/pinecone-python-client/blob/7ff4ed877ac3e97eb557b747a072a84e57764b91/pinecone/core/client/configuration.py#L493

Solution

The change I made was actually modifying the reference to Config.OPENAPI_CONFIG which overwrote things across the board.

Instead of operating on the singleton's instance of the config, we can use copy.deepcopy(Config.OPENAPI_CONFIG) and use that to construct things before handing it off to ApiClient

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Test Plan

Pull this branch down, use the client locally and make sure that dataplane calls work properly without a host or with one in the case of supplying a custom control plane URL.

@austin-denoble
austin-denoble requested a review from jhamon October 17, 2023 19:22
Comment thread pinecone/manage.py

def _get_api_instance():
client_config = Config.OPENAPI_CONFIG
client_config = copy.deepcopy(Config.OPENAPI_CONFIG)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is what we're doing in index.py, I think it's probably prudent to do that here as well rather than possibly changing fields on the singleton.

https://github.com/pinecone-io/pinecone-python-client/blob/7ff4ed877ac3e97eb557b747a072a84e57764b91/pinecone/index.py#L92

@austin-denoble
austin-denoble merged commit 13646fa into main Oct 17, 2023
@austin-denoble
austin-denoble deleted the adenoble/fix-custom-host branch October 17, 2023 19:52
NishchayMahor pushed a commit to NishchayMahor/python-sdk-1 that referenced this pull request Sep 22, 2026
…inecone-io#127) (pinecone-io#221)

* feat(assistant)!: 2026-07 chat/chat_completions/context conformance (pinecone-io#127)

Claim the three assistant_data chat operations for the 2026-07 conformance
suite and align the sync chat surface with the spec's enum churn.

The spec's assistant_data servers url has no path component, but the data
plane is mounted under /assistant — the backend builds its own Location
headers that way and the SDK has always sent that prefix. Rather than
relax the path assertion, the divergence list grows a base_path_overrides
section under the same no-silent-exceptions contract as response-schema
divergences: question issue by number plus a reason, folded into the
manifest per operation, with what the spec declares kept visible in
spec_base_path and the referenced issue checked by --gate.

StreamMessageEnd gains finish_reason, which the OAS marks required on
MessageEndModel and the SDK silently dropped, and FileReference gains
type, which every TypedReferenceModel variant requires and without which
a spec-conformant context fixture cannot round-trip.

Model names: docstrings now list the per-endpoint 2026-07 sets. The
backend still accepts claude-3-5-sonnet/claude-3-7-sonnet as deprecated
aliases remapped to claude-sonnet-4-5, and accepts gpt-5 on
chat_completions although the spec omits it there — both recorded on pinecone-io#220
and documented backend-first rather than promised as rejections.

* test(conformance): cover the base_path_overrides loader and its manifest fold-in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants