GitAuto: describe_image encountered an BadRequestError: Error code: 400 - {'error': {'message': "You uploa... #452
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #451
Why the bug occurs
The
describe_image
function attempts to upload unsupported image formats, such as SVG files, resulting in aBadRequestError
with error code 400. This occurs because the API only accepts specific formats like PNG, JPEG, GIF, and WEBP.How to reproduce
describe_image
function to upload an SVG file.BadRequestError
indicating an unsupported image format.Where / How to code and why
Modify
services/openai/instructions/describe_image.py
to include validation for image formats before uploading. Implement the following steps:png
,jpeg
,gif
,webp
). If it's an unsupported format likesvg
, proceed to the next step.requirements.txt
to handle image processing.This approach ensures that all images uploaded through the
describe_image
function are in supported formats, thereby preventingBadRequestError
instances and improving the robustness of the application.Anything the issuer needs to do
No action required.
Test these changes locally