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

Prevent _get_api_instance from modifying OpenAPI config #221

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

austin-denoble
Copy link
Contributor

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

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
@@ -49,7 +50,7 @@ def __str__(self):


def _get_api_instance():
client_config = Config.OPENAPI_CONFIG
client_config = copy.deepcopy(Config.OPENAPI_CONFIG)
Copy link
Contributor 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.

openapi_client_config = copy.deepcopy(Config.OPENAPI_CONFIG)

@austin-denoble austin-denoble merged commit 13646fa into main Oct 17, 2023
5 checks passed
@austin-denoble austin-denoble deleted the adenoble/fix-custom-host branch October 17, 2023 19:52
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