ganeshdipdumbare / marqo-go

Go client for Marqo.ai multimodal vector search
MIT License
2 stars 1 forks source link

Send error response body on req error #13

Open brianfeister opened 2 weeks ago

brianfeister commented 2 weeks ago

Right now this library just says error searching if marqo sends an error, which makes it very difficult to debug an incorrect request body. It would be great if we sent back the marqo response body for debugging purposes!

I can put up a PR for this when I'm a bit less busy (cc @msnorth ) but the way the imroc/req pkg only sends back 400 and not the actual body content from marqo is a real challenge for debugging

At this line https://github.com/ganeshdipdumbare/marqo-go/blob/main/search.go#L263 we could use .EnableReqDump() from the Imroc req pkg docs: https://github.com/imroc/req?tab=readme-ov-file#advanced-get

EnableDump(). // Enable dump at request level, only print dump content if there is an error or some unknown situation occurs to help troubleshoot.

brianfeister commented 2 weeks ago

Something along these lines:

    var errMsg string // properly type me!
    resp, err := c.reqClient.
        R().
        SetQueryParams(queryParams).
        SetBody(searchReq).
        SetErrorResult(&errMsg).
                 EnableDump().
        SetSuccessResult(&searchResp).
        Post(c.reqClient.BaseURL + "/indexes/" + searchReq.IndexName + "/search")
ganeshdipdumbare commented 2 weeks ago

@brianfeister Thanks for pointing it out. I guess its good for debugging for sure. I think the only case where we need to set is if the log level is debug? WDYT?