GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat: Pass through data URLs directly and gracefully handle unknown U… by yxshee · Pull Request #12592 · anomalyco/opencode Conversation
|
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #12549: fix(desktop): windows clipboard images come thru as data not file This PR is directly related to the current PR #12592. Both address the same issue: handling clipboard images on Windows that come through as |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixes a crash when handling clipboard-pasted images (e.g., Windows 11 data:image/png;base64,...) by preventing data: URLs from falling through to file: handling and by adding a safe fallback for previously-unhandled URL protocols in SessionPrompt.
Changes:
text/plain data: URL file parts (e.g., images/PDFs) without attempting fileURLToPath().default branch in the URL protocol switch to avoid unhandled protocols causing failures/dropped parts.💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ] | ||
| default: | ||
| // Handle unknown protocols gracefully to prevent crashes | ||
| log.warn("unsupported URL protocol", { protocol: url.protocol, url: part.url.slice(0, 100) }) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The default-case log includes a prefix of the full URL (part.url.slice(0, 100)), which can leak sensitive user data (e.g., signed URLs/tokens in query strings). Consider logging only the protocol plus a redacted/sanitized identifier (e.g., hostname for http(s), or just url.protocol/mime/length), and avoid logging the URL itself at warn level.
| log.warn("unsupported URL protocol", { protocol: url.protocol, url: part.url.slice(0, 100) }) | |
| log.warn("unsupported URL protocol", { | |
| protocol: url.protocol, | |
| mime: part.mime, | |
| filename: part.filename, | |
| }) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| default: | ||
| // Handle unknown protocols gracefully to prevent crashes | ||
| log.warn("unsupported URL protocol", { protocol: url.protocol, url: part.url.slice(0, 100) }) | ||
| return [ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The default branch labels any non-data:/file: URL as "unsupported" and emits a warn. The codebase can create http: URLs for image parts (see packages/opencode/src/acp/agent.ts where part.uri.startsWith("http:") becomes a file part), and those may be valid to pass through to providers. Consider adding explicit case "http:":/"https:": to pass through without warning, or change the log message/level to reflect "unhandled" rather than "unsupported" to avoid noisy/misleading logs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // For non-text data URLs (images, PDFs from clipboard), pass through as-is | ||
| log.info("data url", { mime: part.mime }) | ||
| return [ | ||
| { | ||
| ...part, | ||
| id: part.id ?? Identifier.ascending("part"), | ||
| messageID: info.id, | ||
| sessionID: input.sessionID, | ||
| }, | ||
| ] |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This change introduces new behavior for non-text data: URLs and unknown protocols. There are existing SessionPrompt tests under packages/opencode/test/session/; please add coverage for (1) data:image/png;base64,... parts to ensure they no longer crash/are preserved, and (2) a non-file:/data: URL (e.g., http:) to ensure it’s handled consistently (and not dropped).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
When pasting images from clipboard on Windows 11, the app crashed with: TypeError: The URL must be of scheme file (ERR_INVALID_URL_SCHEME) Root cause: The data: case only handled text/plain and broke, causing non-text data URLs to fall through to file: case which called fileURLToPath() on a data: URL. Fix: - Return non-text data URLs directly instead of breaking - Add default case to prevent fall-through for unknown protocols
… warning message.
|
Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Crash on Windows when pasting images from clipboard (ERR_INVALID_URL_SCHEME)
There was an error while loading. Please reload this page.