-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add Host
normalization when building IndexConnection
#56
Conversation
@@ -1007,6 +1007,16 @@ func (idx *IndexConnection) delete(ctx context.Context, req *data.DeleteRequest) | |||
return err | |||
} | |||
|
|||
func (idx *IndexConnection) akCtx(ctx context.Context) context.Context { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this up to group with the other IndexConnection
methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bit of an oddity with stripping http://
from a host then defaulting to port 443 with TLS enabled on the connection.
pinecone/index_connection_test.go
Outdated
{ | ||
name: "http:// scheme should be removed", | ||
host: "http://this-is-my-host.io", | ||
expectedHost: "this-is-my-host.io:443", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit odd... I would expect a http://
transport to default to port 80.
However, I also don't see a user specifying http plaintext without a port for an index.
@@ -3,8 +3,9 @@ package pinecone | |||
import ( | |||
"context" | |||
"crypto/tls" | |||
"fmt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is meant to be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was in my original PR because I removed the target := fmt.Sprintf("%s:443", in.host)
which was the only usage in here previously.
Once rebasing on your changes though we have those fmt.Errorf
calls with the input struct checking.
name: "http:// scheme without a port should be removed", | ||
host: "http://this-is-my-host.io", | ||
expectedHost: "this-is-my-host.io:443", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference btwn this test and the 1st test? It looks like they both start and end with the same values, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nothing, accidentally duplicated it!
name: "http:// scheme and port should be maintained", | ||
host: "http://this-is-my-host.io:8080", | ||
expectedHost: "http://this-is-my-host.io:8080", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to add an iteration here that does https
with a port, too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think I meant to add that case and kept one the same through copy pasta or something. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing blocking, just some Qs. Great job!
… newIndexConnection, add unit tests
…coming uri, update unit tests
b1dca21
to
8533c61
Compare
Problem
We had an issue that was logged around trying to call
Client.Index()
with aHost
value including anhttp://
orhttps://
schema. The control plane does not attach these schemes, but when building anIndexConnection
a user needs to provide a host and they could make this mistake.grpc-go
is not expecting atarget
inNewClient
that includes a scheme.We could do a bit of normalization to handle the
Host
more thoroughly.Solution
normalizeHost
helper function inindex_connection.go
. This strips outhttp://
&https://
prefixes, and attaches the port:443
unless the user has provided one directly. We want to leave some flexibility for making RPCs in specific scenarios.normalizeHost
.Type of Change
Test Plan
CI unit & integration tests should pass as normal.
To test manually, you can try and prepend schemes to the Host when calling
client.Index()