pinecone-io / go-pinecone

Pinecone.io Golang Client
Apache License 2.0
49 stars 9 forks source link

[Bug] Cannot list vectors, getting missing HTTP content-type error #87

Open maxheckel opened 1 month ago

maxheckel commented 1 month ago

Is this a new bug?

Describe the bug I have the following code:

package main

import (
    "context"
    "encoding/json"
    "fmt"
    "log"

    "github.com/pinecone-io/go-pinecone/pinecone"
    _ "google.golang.org/protobuf/types/known/structpb"
)

func main() {
    ctx := context.Background()

    client, err := pinecone.NewClient(pinecone.NewClientParams{
        ApiKey: "REDACTED",
    })
    if err != nil {
        log.Fatalf("Failed to create Client: %v", err)
    }
    index, err := client.Index(pinecone.NewIndexConnParams{
        Host:      "REDACTED",
        Namespace: "REDACTED",
    })
    if err != nil {
        log.Fatalf("Failed to initialize index: %v", err)
    }

    res, err := index.ListVectors(ctx, &pinecone.ListVectorsRequest{
        Prefix:          nil,
        Limit:           nil,
        PaginationToken: nil,
    })
    if err != nil {
        log.Fatalf("Failed to describe index stats: %v", err)
    }

    fmt.Println(res)
}

When running it I get the following output: 2024/10/24 14:04:37 Failed to describe index stats: rpc error: code = Unknown desc = malformed header: missing HTTP content-type

Error information n/a

Steps to reproduce the issue locally Run the code above My go.mod looks like this:

module ai-experiments

go 1.21

require (
    github.com/pinecone-io/go-pinecone v1.1.1
    google.golang.org/protobuf v1.34.1
)

require (
    github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
    github.com/davecgh/go-spew v1.1.1 // indirect
    github.com/google/uuid v1.6.0 // indirect
    github.com/oapi-codegen/runtime v1.1.1 // indirect
    github.com/pmezard/go-difflib v1.0.0 // indirect
    github.com/stretchr/testify v1.8.4 // indirect
    golang.org/x/net v0.25.0 // indirect
    golang.org/x/sys v0.20.0 // indirect
    golang.org/x/text v0.15.0 // indirect
    google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
    google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
    google.golang.org/grpc v1.65.0 // indirect
    gopkg.in/yaml.v3 v3.0.1 // indirect
)

Environment

austin-denoble commented 1 week ago

Hey @maxheckel, this is an error we've seen in integration tests when attempting to interact with an index before it's in a ready state.

Is the Host value that you're passing with NewIndexConnParams associated with an index that had been created previously and have you upserted vectors to it?

If you have the index name you should be able to use the name to call client.DescribeIndex("YOUR_INDEX_NAME") and then check the response for Status.State or Status.Ready to verify the state of the index.