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 normalizeHost, allow for non-secure connections #74

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

austin-denoble
Copy link
Contributor

@austin-denoble austin-denoble commented Sep 13, 2024

Problem

When working with specific environments and hosts that require a non-secure connection, calling pc.Index(pinecone.NewIndexConnParams{Host: idx.Host}) with a Host value that is insecure, you'll run into unexpected behavior seeing :443 attached as a port, or gRPC errors around connecting insecurely without explicitly passing a grpc.DialOption.

Our normalizeHost function has a bug in that it applies port :443 to Host values which are passed without an explicit scheme.

Solution

  • We can simplify the normalizeHost function to only deal with stripping away any provided scheme, and then checking to see if the connection is explicitly insecure. This is accomplished by providing http:// as a part of the NewIndexConnParams{ Host: yourHost } value, which would need to be accounted for in documentation, etc.

This felt most straightforward because of how the grpc module handles host addresses. Ultimately, we need to strip the scheme off any hosts that are passed, but we also need to decide whether we're dialing in a secure or insecure fashion. I thought of providing an explicit bool as a part of the NewIndexConnParams, but it felt more unwieldy adding new fields.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

I have a local test harness that I'm using to interact with a locally hosted index. I was overriding the go-pinecone package in go.mod to work against my local copy of the SDK. You can pull this branch down and do something similar locally. Here are some of my results:

Before

Screenshot 2024-09-12 at 10 09 45 PM

After

Screenshot 2024-09-12 at 10 33 59 PM

…st values passed to newIndexConnection, update unit tests
Copy link
Contributor

@haruska haruska left a comment

Choose a reason for hiding this comment

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

👍

@austin-denoble austin-denoble merged commit 64f1d68 into main Sep 13, 2024
2 checks passed
@austin-denoble austin-denoble deleted the adenoble/fix-normalize-host branch September 13, 2024 15:06
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