weaviate / weaviate-go-client

BSD 3-Clause "New" or "Revised" License
29 stars 11 forks source link

weaviate-go-client not working with WCS instance using grpc #220

Closed jfrancoa closed 3 months ago

jfrancoa commented 4 months ago

When trying to connect to a WCS sandbox using the gRPC connection the creation of the class and addition of objects fails with the following error: "unexpected HTTP status code received from server: 404 (Not Found); transport: received unexpected content-type \"text/html\""

The code used to reproduce the issue is the following:

package main

import (
    "context"
    "fmt"

    "github.com/go-openapi/strfmt"
    "github.com/weaviate/weaviate-go-client/v4/weaviate"
    "github.com/weaviate/weaviate-go-client/v4/weaviate/auth"
    "github.com/weaviate/weaviate-go-client/v4/weaviate/grpc"
    "github.com/weaviate/weaviate/entities/models"
)

func GetSchema() {
    ctx := context.TODO()
    cfg := weaviate.Config{
        Host:       "<WCS_HOST_NAME>",
        Scheme:     "https",
        AuthConfig: auth.ApiKey{Value: "<API_KEY>"},
        Headers:    nil,
        GrpcConfig: &grpc.Config{Host: "<WCS_GRPC_HOST>", Secured: true},
    }
    // cfg := weaviate.Config{
    //  Host:       "localhost:8080",
    //  Scheme:     "http",
    //  Headers:    nil,
    //  GrpcConfig: &grpc.Config{Host: "localhost:50051"},
    // }
    client, err := weaviate.NewClient(cfg)
    if err != nil {
        panic(err)
    }

    if exists, _ := client.Schema().ClassExistenceChecker().WithClassName("Wine").Do(ctx); exists {
        client.Schema().ClassDeleter().WithClassName("Wine").Do(ctx)
    }
    id := "d3ae0320-a532-4e7b-9a89-6064263a182a"
    className := "Wine"

    obj := &models.Object{
        ID:    strfmt.UUID(id),
        Class: className,
        Properties: map[string]interface{}{
            "name": "Classic Wine",
        },
    }
    resp, err := client.Batch().ObjectsBatcher().WithObjects(obj).Do(ctx)
    if err != nil {
        panic(err)
    }
    if len(resp) != 1 {
        panic("Expected 1 response")
    }

    schema, err := client.Schema().Getter().Do(context.Background())
    if err != nil {
        panic(err)
    }
    // print the schema in readable format
    fmt.Printf("%+v", schema)
}

func main() {
    GetSchema()
}

Make sure to replace the config values in capital letters by your WCS sandbox instance ones.

After, that Config struct there is a commented one that helps verifying that the same test works on a local Weaviate instance, but when connecting via grpc to WCS the failure occurs.

dirkkul commented 3 months ago

I just tried to reproduce this, but it worked for a newly created sandbox - could you double check if this is still an issue? Closing for now