-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
translator: handling for OpenAI and AWSBedrock error response #152
Conversation
can you fix the e2e |
if v, ok := headers[statusHeaderName]; ok && v != string(typev3.StatusCode_OK) { | ||
return nil, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not necessary or should be panic... if we reach this, that means a bug in extproc code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually for header processing we need this check otherwise it continues processing the event stream header mutation.
extprocapi/extproc.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary change?
so i made it easy to add the end-to-end transformation testing with testupstream here:
feel free to add more cases to cover this case (maybe some fix might be necessary for the test as well as testupstream) |
Signed-off-by: Dan Sun <[email protected]>
Signed-off-by: Dan Sun <[email protected]>
Signed-off-by: Dan Sun <[email protected]>
425230d
to
7acccb4
Compare
Signed-off-by: Dan Sun <[email protected]>
Signed-off-by: Dan Sun <[email protected]>
Signed-off-by: Dan Sun <[email protected]>
675ee46
to
8b1c09d
Compare
Signed-off-by: Dan Sun <[email protected]>
if v, err := strconv.Atoi(v); err == nil { | ||
if !isGoodStatusCode(v) { | ||
return nil, nil | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also i am still not sure why if this is a bad status code we can continue and when good we return early. could you put the detailed code comments. This will be hard to understand by anyone without the extensive knowledge. I believe the comments will be helpful for future contributors (including me!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote the code in a way that it does not require this logic. Before it incorrectly returns a content type check error on error response. I am not a fan of writing too much code comments which means the code is not self-explainable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo i need code comments!
Signed-off-by: Dan Sun <[email protected]>
Signed-off-by: Dan Sun <[email protected]>
Added the tests all ready to go |
Will take a look with an hour! |
Add handling for the OpenAI and Bedrock error response. Currently when error response is returned it fails on decoding the
ConverseOutput
orOpenAIChatCompletionResponse
as it is assuming a 200 response.For AWSBedrock the error response is converted to OpenAIError type when returning to the user. For OpenAI error response we return directly back without translation. In case of connection errors to the AWS Bedrock or OpenAI backend, we translate to OpenAIError type based on the status code and message body.
fixes #133