-
-
Notifications
You must be signed in to change notification settings - Fork 44
fix(adapters): handle image fetch failures gracefully #701
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
Conversation
Improve error handling across all adapters when fetching images fails. Changes ensure that failed image operations don't break message processing: - Return null from image processing functions on fetch errors - Filter out null values from processed content arrays - Convert langchainMessageToHunyuanMessage to async for image processing - Add try-catch blocks around image URL fetching in all adapters - Remove image content entries when fetch fails instead of falling back This allows the chat to continue with text content even if image fetching fails, improving robustness when dealing with broken or inaccessible image URLs.
Walkthrough跨多个适配器包的图像URL处理改进。包括更好的错误处理(记录构建的rawUrl而非未定义变量)、过滤空值结果、改用Promise.all进行并行处理,以及在Hunyuan适配器中引入异步图像获取。 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @dingyi222666, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the resilience of the system's various adapters by introducing robust error handling mechanisms for image fetching operations. By ensuring that image fetch failures do not halt message processing and instead allow for graceful degradation, the changes improve the overall stability and user experience. The update also standardizes error handling practices and refines asynchronous operations where image processing is involved. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request improves error handling for image fetching across various adapters, preventing crashes when an image URL is inaccessible. However, by systematically moving image fetching from LLM providers to the server side, it introduces Server-Side Request Forgery (SSRF) vulnerabilities in the OpenAI, Hunyuan, Qwen, and Zhipu adapters, as user-provided URLs are fetched without validation. It is highly recommended to implement URL validation (e.g., restricting to public IPs and allowed protocols) before performing network requests on the server. Furthermore, error logging was missed in some new try-catch blocks, which should be added to improve diagnostics and ensure all image fetch failures are visible.
Summary
This PR improves error handling across all adapters when image fetching fails, ensuring that broken or inaccessible image URLs don't break message processing.
Bug fixes
Other Changes