azure-search-openai-demo
azure-search-openai-demo copied to clipboard
Pass along status codes for errors
Purpose
I realized during loadtesting that RateLimitError is being returned as a 500. This PR adjusts the error handling code so that the status code is passed along, and they'll show as 429 instead.
Does this introduce a breaking change?
[ ] Yes
[X] No
Pull Request Type
What kind of change does this Pull Request introduce?
[X] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:
How to Test
- Added a new unit test with mock
Hm. Now I'm debating if it actually should be a 500.. as other errors should probably be 500s: https://github.com/openai/openai-python/blob/a7115b5f33acd27326e5f78e19beb0d73bd3268e/src/openai/_exceptions.py
Or I could treat 429 specially and keep treating others as 500s.
I decided not to do this, as it doesn't feel okay to pass down errors to users that are often errors with the server code, not with their own usage of the app. We should only pass down error codes that are definitely a user eror, like the content_safety_filter (and we pass that now as a 400). Closing!