-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix: improve image URL parsing robustness across providers #8383
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
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.
1 issue found across 7 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="core/llm/llms/Ollama.ts">
<violation number="1" location="core/llm/llms/Ollama.ts:308">
Calling extractBase64FromDataUrl here will throw on malformed data URLs and bubble up, regressing the previous behavior that tolerated bad input; wrap this in error handling or preserve the non-throwing fallback so malformed URLs don’t crash message conversion.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
RomneyDa
left a comment
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.
@dcs-soni looks like some tests are failing and see cubic feedback!
92ee1ac to
64f3e12
Compare
|
|
||
| import { fromNodeProviderChain } from "@aws-sdk/credential-providers"; | ||
| import { fromStatic } from "@aws-sdk/token-providers"; | ||
| import { parseDataUrl } from "../../../../core/util/url.js"; |
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.
@dcs-soni openai-adapters doesn't have access to core but core has openai-adapters, you could put the util in openai-adapters and pull it from there within core!
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.
(this is what is causing the lint failures)
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.
Got it. Fixed this. Thanks!
d3c2caa to
b4526bf
Compare
|
Phew! Had some trouble running Continue locally on Windows. Would send PRs to improve the local development experience if I find good fixes. |
RomneyDa
left a comment
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.
@dcs-soni appreciate the updates and contribution!
|
@dcs-soni there's definitely room for improvement for local development especially for onboarding contributors! Any improvements appreciated |
|
🎉 This PR is included in version 1.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.36.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
Handle malformed data URLs in Bedrock, Anthropic, Gemini, and Ollama adapters. Currently, they use unsafe array destructuring when parsing data URLs, causing runtime crashes on malformed input or unexpected results even if the parsed data is not correct base64.
Data URLs can be malformed due to various reasons, like, copy/paste from applications generating invalid URLs, user provided code containing malformed base64 URLs or maybe a network connection during image uploads.
This fix:
AI Code Review
@continue-reviewChecklist
Screen recording or screenshot
[ When applicable, please include a short screen recording or screenshot - this makes it much easier for us as contributors to review and understand your changes. See this PR as a good example. ]
Tests
[ What tests were added or updated to ensure the changes work as expected? ]
Summary by cubic
Improved image data URL parsing across providers to prevent crashes on malformed inputs. Centralizes parsing in the openai-adapters package with safer base64 extraction and MIME type handling.
Bug Fixes
Refactors
Written for commit 1c7668c. Summary will update automatically on new commits.