Closed dexp-io closed 7 months ago
@dexp-io
I'm not able to understand this issue -- can you please elaborate?
when document updated, always return error with map[]{ status:201, response : "the same interface sended" }
I have the same error, is anyone working on the issue
Can you post a small code sample that reproduces the issue that I can run and check?
Sorry for the late response. Here are the small example that shows the issue:
docker-compose.yml
services:
typesense:
image: typesense/typesense:0.25.0
restart: on-failure
ports:
- "8110:8108"
volumes:
- ./typesense-data:/data
command: '--data-dir /data --api-key=xyz --enable-cors'
client.go
package main
import ( "fmt"
"github.com/typesense/typesense-go/typesense"
"github.com/typesense/typesense-go/typesense/api"
"github.com/typesense/typesense-go/typesense/api/pointer"
)
func main() { // create client client := typesense.NewClient( typesense.WithServer("http://localhost:8110"), typesense.WithAPIKey("xyz"))
// create schema
schema := &api.CollectionSchema{
Name: "companies",
Fields: []api.Field{
{
Name: "company_name",
Type: "string",
},
{
Name: "num_employees",
Type: "int32",
},
{
Name: "country",
Type: "string",
Facet: pointer.True(),
},
},
DefaultSortingField: pointer.String("num_employees"),
}
client.Collections().Create(schema)
// create document
document := struct {
ID string `json:"id"`
CompanyName string `json:"company_name"`
NumEmployees int `json:"num_employees"`
Country string `json:"country"`
}{
ID: "123",
CompanyName: "Stark Industries",
NumEmployees: 5215,
Country: "USA",
}
client.Collection("companies").Documents().Create(document)
// update document
d := struct {
CompanyName string `json:"company_name"`
NumEmployees int `json:"num_employees"`
}{
CompanyName: "Stark Industries",
NumEmployees: 5500,
}
res, err := client.Collection("companies").Document("123").Update(d)
if err != nil {
fmt.Printf("err: %v\n", err)
}
fmt.Printf("res: %v\n", res)
}
server is updating the document successfully with `201` status code, but the response is returning in the position of error.
```sh
err: status: 201 response: {"company_name":"Stark Industries","country":"USA","id":"123","num_employees":5500}
res: map[]
yes, I have the same issue! I opened a PR fixing it!
I confirm the issue, I have it too. Thank you for taking care of this. 🙂
The actual issue here was with Typesense server: it should not be returning a 201 status code for the update operation since 201 can only be returned when a new resource is created. This was an oversight on our part. This has been fixed in Typesense 0.25.2 -- please upgrade to this version. I will be closing this issue, since a patch on the client is no longer required.
There was a typo in my earlier comment. Please use Typesense 0.25.2
to ensure that you don't run into this issue.
Description
Erorr: status: 201 response: {....}
Metadata
Typesense Version: v0.25
OS: Linux