Skip to content
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

GitAuto: describe_image encountered an BadRequestError: Error code: 400 - {'error': {'message': "You uploa... #452

Closed
wants to merge 2 commits into from

Conversation

gitauto-ai[bot]
Copy link

@gitauto-ai gitauto-ai bot commented Dec 30, 2024

Resolves #451

Why the bug occurs

The describe_image function attempts to upload unsupported image formats, such as SVG files, resulting in a BadRequestError with error code 400. This occurs because the API only accepts specific formats like PNG, JPEG, GIF, and WEBP.

How to reproduce

  1. Use the describe_image function to upload an SVG file.
  2. The function raises a 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:

  1. Validate Image Format: Check if the uploaded image is in one of the supported formats (png, jpeg, gif, webp). If it's an unsupported format like svg, proceed to the next step.
  2. Convert Unsupported Formats: Use the Pillow library to convert unsupported image formats (e.g., SVG) to a supported format such as PNG.
  3. Handle Conversion Errors: Implement error handling to manage any issues that arise during the conversion process, ensuring that meaningful error messages are logged and returned.
  4. Update Dependencies: Ensure that the Pillow library is included in requirements.txt to handle image processing.

This approach ensures that all images uploaded through the describe_image function are in supported formats, thereby preventing BadRequestError instances and improving the robustness of the application.

Anything the issuer needs to do

No action required.

Test these changes locally

git fetch origin
git checkout gitauto/issue-451-20241230-042832
git pull origin gitauto/issue-451-20241230-042832

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

describe_image encountered an BadRequestError: Error code: 400 - {'error': {'message': "You uploa...
1 participant