You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior
I tried to google some solutions. Some said it was because of the proxy, and some said it was a situation that could only be reproduced by chance. My previous project also used go-openai, version v1.26.0, and the same update operation was successful in the previous project. By printing the context, client and request parameters, they are almost the same. Therefore, I judged that there was no problem with my code, and it might be other abnormalities.
When I upgraded to v1.29.0, the issue still exists.
Screenshots/Logs
error, status code: 403, message: invalid character '<' looking for beginning of value
Environment (please complete the following information):
go-openai version: go-openai v1.27.0
Go version: version go1.22.5
OpenAI API version: [e.g. v2]
OS: [e.g. Ubuntu 20.04]
The text was updated successfully, but these errors were encountered:
I just sporadically got this same error after upgrading from v1.28.1 to v1.29.1 and calling CreateChatCompletion with a JSON schema for the new structured output feature, but the upgrade may just be a coincidence because I'm having a hard time reproducing with either version. I did some quick web searching, and it seems that the Go Stripe client had a similar issue which was resolved by this PR.
The long and the short of it is that with HTTP/2, it's not always safe to reuse an HTTP request from the Go http package. More details here and here. The Go Stripe issue was happening inside of a retry loop, and refreshing the request body on each iteration did the trick there.
For what it's worth, my error occurred within a retry loop in my application, but even so, I don't see any way that the code path could result in reusing the underlying request or the body at all.
@WangQuanTang are you reliably getting this error every time?
Oh, I just noticed error status code 403 in your log output. I see the problem now. That status code is http.StatusForbidden which means the response gets processed by handleErrorResp as called from sendRequest.
That function attempts to parse the response body under the assumption that it's in JSON format, but the OpenAI API must be responding with HTML which is causing the JSON decoder to fail with this error message about the invalid character when it encounters an HTML tag.
Your problem seems to be that your API key isn't working. My problem must have been a sporadic service issue with the API. Maybe the failure result processing can be improved to make it more obvious what the problem is when this happens in either scenario.
Your issue may already be reported!
Please search on the issue tracker before creating one.
Describe the bug
When I do an update to assistant it says: "error, status code: 403, message: invalid character '<' looking for beginning of value"
To Reproduce
Expected behavior
I tried to google some solutions. Some said it was because of the proxy, and some said it was a situation that could only be reproduced by chance. My previous project also used
go-openai
,version v1.26.0
, and the same update operation was successful in the previous project. By printing the context, client and request parameters, they are almost the same. Therefore, I judged that there was no problem with my code, and it might be other abnormalities.When I upgraded to v1.29.0, the issue still exists.
Screenshots/Logs
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: