Repository navigation
Fix #692 [Bug]: Passing invalid parameters to gemini throws Undefined… - #693
alxlab-zone66x wants to merge 3 commits into
Conversation
… Undefined array key "choices" /www/htdocs/vendor/openai-php/client/src/Responses/Chat/CreateResponse.php 54 Change-Id: Ibbf64cc554ef68844fd8338583f3fc8ec5fde413
iBotPeaches
left a comment
There was a problem hiding this comment.
Could you add a test to confirm this? I think the HttpTransporter tests is the area to make a formulated Gemini exception to confirm this.
|
Yeah sure. That would make sense. |
|
Hmm for the
|
Probably the message/status of the higher object. I think you can ignore inner details stuff. |
… Undefined array key "choices" /www/htdocs/vendor/openai-php/client/src/Responses/Chat/CreateResponse.php 54 Add tests for gemini with invalid parameter. Set ErrorException type to return error status for invalid gemini parameter. Change-Id: I076016d0470eb3060d3f972702e4e3701b52207d
54d60ea to
6591d36
Compare
| if (! isset($data[0]['error']['type']) && isset($data[0]['error']['status'])) { | ||
| $data[0]['error']['type'] = $data[0]['error']['status']; | ||
| } |
There was a problem hiding this comment.
This check is the only thing I'm iffy on right now. I'd rather the ErrorException class navigate the water of different error structures to normalize them. So the HTTPTransporter isn't required to formulate things perfectly for an exception class.
|
Hi! Any update on this? Maybe Google should fix it ? I suppose every SDK has issues with error payloads ? |
|
I wish Google would fix it. If you are making a parity API for OpenAI, at least make it match. My last comment is still outstanding. |
Gemini's OpenAI-compatible endpoints name the kind of error `status` (`INVALID_ARGUMENT`), not `type`, so `ErrorException::getErrorType()` returned null for every error they raise. `type` keeps precedence when a payload carries both. Normalize it in the exception rather than in the transporter, as asked on openai-php#693, so both construction sites are covered: the whole-response one in HttpTransporter and the SSE frame one in StreamResponse. Widen the error payload shapes at those two sites, which declared `type` as required and knew nothing of `status`. Co-authored-by: alxlab-zone66x <85719219+alxlab-zone66x@users.noreply.github.com>
Gemini's OpenAI-compatible endpoints name the kind of error `status` (`INVALID_ARGUMENT`), not `type`, so `ErrorException::getErrorType()` returned null for every error they raise. `type` keeps precedence when a payload carries both, and a `status` that is not a string is ignored: plenty of providers put the HTTP status there as an integer, and this getter returns `?string`. Normalize it in the exception rather than in the transporter, as asked on openai-php#693, so both construction sites are covered: the whole-response one in HttpTransporter and the SSE frame one in StreamResponse. Widen the error payload shapes at those two sites, which declared `type` as required and knew nothing of `status`. Co-authored-by: alxlab-zone66x <85719219+alxlab-zone66x@users.noreply.github.com>
Gemini's OpenAI-compatible endpoints name the kind of error `status` (`INVALID_ARGUMENT`), not `type`, so `ErrorException::getErrorType()` returned null for every error they raise. `type` keeps precedence when a payload carries both, and a `status` that is not a string is ignored: plenty of providers put the HTTP status there as an integer, and this getter returns `?string`. Normalize it in the exception rather than in the transporter, as asked on openai-php#693, so both construction sites are covered: the whole-response one in HttpTransporter and the SSE frame one in StreamResponse. Widen the error payload shapes at those two sites, which declared `type` as required and knew nothing of `status`. Co-authored-by: alxlab-zone66x <85719219+alxlab-zone66x@users.noreply.github.com>
… array key "choices" /www/htdocs/vendor/openai-php/client/src/Responses/Chat/CreateResponse.php 54
Change-Id: Ibbf64cc554ef68844fd8338583f3fc8ec5fde413
What:
Description:
Related:
Fix issue #692