[PR #18432] [MERGED] fix: correctly handle clipboard images with {{CLIPBOARD}} in prompts #63649

Closed
opened 2026-05-06 08:33:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/18432
Author: @silentoplayz
Created: 10/20/2025
Status: ✅ Merged
Merged: 10/28/2025
Merged by: @tjbck

Base: dev ← Head: fix-clipboard-image-paste


📝 Commits (1)

  • 0031fb8 fix: correctly handle clipboard images in prompts

📊 Changes

1 file changed (+15 additions, -14 deletions)

View changed files

📝 src/lib/components/chat/MessageInput.svelte (+15 -14)

📄 Description

Before submitting, make sure you've checked the following:

  • Target branch: Verify that the pull request targets the dev branch. Not targeting the dev branch may lead to immediate closure of the PR.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: If necessary, update relevant documentation Open WebUI Docs like environment variables, the tutorials, or other documentation sources.
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Perform manual tests to verify the implemented fix/feature works as intended AND does not break any other functionality. Take this as an opportunity to make screenshots of the feature/fix and include it in the PR description.
  • Agentic AI Code:: Confirm this Pull Request is not written by any AI Agent or has at least gone through additional human review and manual testing. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR.
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Title Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

Description

  • This pull request addresses a bug where images pasted into the chat input via a {{CLIPBOARD}} prompt variable were not being handled correctly. The issue stemmed from the image data being passed as a blob URL instead of the required base64-encoded data URL, leading to backend processing errors. The fix ensures that clipboard images are properly converted to base64 before being sent, resolving the bug and improving clipboard functionality, especially for Firefox users.

Changed

  • Updated the textVariableHandler function in src/lib/components/chat/MessageInput.svelte to use FileReader.readAsDataURL() for encoding clipboard images.
  • Added error handling for navigator.clipboard.read() to gracefully manage clipboard permission issues.

Fixed

  • Resolves the "'url' field must be a base64 encoded image" error by ensuring pasted images are correctly formatted.
  • Fixes the "400: illegal base64 data at input byte 4" error by providing a valid base64 string to the backend.
  • Prevents the "messages[0].content must be a string" error by ensuring the message payload is correctly constructed.
  • Addresses a DOMException in Firefox related to clipboard read permissions.

Additional Information

  • This change aligns the behavior of pasting images via the {{CLIPBOARD}} variable with the direct Ctrl+V paste functionality, creating a more consistent user experience.
  • The fix directly addresses the root cause of multiple reported frontend errors, all of which were symptomatic of the same base64 encoding issue.
  • This PR solves https://github.com/open-webui/open-webui/issues/18425
  • This PR DOES NOT solve the following:
    image

Testing

  • I have tested the changes made in this PR to ensure there are no regressions or issues caused with other methods of adding an image to the chat input field in a chat before sending it off to a vision model. This PR only solves issues and does not cause any itself based on my testing concluded.

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
translations of the new items added in the last version have been carried out.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/18432 **Author:** [@silentoplayz](https://github.com/silentoplayz) **Created:** 10/20/2025 **Status:** ✅ Merged **Merged:** 10/28/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `fix-clipboard-image-paste` --- ### 📝 Commits (1) - [`0031fb8`](https://github.com/open-webui/open-webui/commit/0031fb82748872c24d68efa03fa7f83b44cd8a23) fix: correctly handle clipboard images in prompts ### 📊 Changes **1 file changed** (+15 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/chat/MessageInput.svelte` (+15 -14) </details> ### 📄 Description **Before submitting, make sure you've checked the following:** - [X] **Target branch:** Verify that the pull request targets the `dev` branch. Not targeting the `dev` branch may lead to immediate closure of the PR. - [X] **Description:** Provide a concise description of the changes made in this pull request. - [X] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [X] **Documentation:** If necessary, update relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs) like environment variables, the tutorials, or other documentation sources. - [X] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [X] **Testing:** Perform manual tests to verify the implemented fix/feature works as intended AND does not break any other functionality. Take this as an opportunity to make screenshots of the feature/fix and include it in the PR description. - [X] **Agentic AI Code:**: Confirm this Pull Request is **not written by any AI Agent** or has at least gone through additional human review **and** manual testing. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR. - [X] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [X] **Title Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry ### Description - This pull request addresses a bug where images pasted into the chat input via a `{{CLIPBOARD}}` prompt variable were not being handled correctly. The issue stemmed from the image data being passed as a blob URL instead of the required base64-encoded data URL, leading to backend processing errors. The fix ensures that clipboard images are properly converted to base64 before being sent, resolving the bug and improving clipboard functionality, especially for Firefox users. ### Changed - Updated the `textVariableHandler` function in `src/lib/components/chat/MessageInput.svelte` to use `FileReader.readAsDataURL()` for encoding clipboard images. - Added error handling for `navigator.clipboard.read()` to gracefully manage clipboard permission issues. ### Fixed - Resolves the "`'url' field must be a base64 encoded image`" error by ensuring pasted images are correctly formatted. - Fixes the "`400: illegal base64 data at input byte 4`" error by providing a valid base64 string to the backend. - Prevents the "`messages[0].content must be a string`" error by ensuring the message payload is correctly constructed. - Addresses a `DOMException` in Firefox related to clipboard read permissions. ### Additional Information - This change aligns the behavior of pasting images via the `{{CLIPBOARD}}` variable with the direct `Ctrl+V` paste functionality, creating a more consistent user experience. - The fix directly addresses the root cause of multiple reported frontend errors, all of which were symptomatic of the same base64 encoding issue. - This PR solves https://github.com/open-webui/open-webui/issues/18425 - This PR **DOES NOT** solve the following: <img width="364" height="216" alt="image" src="https://github.com/user-attachments/assets/9808cde8-8f1d-4997-9cec-86d076a51415" /> ### Testing - I have tested the changes made in this PR to ensure there are no regressions or issues caused with other methods of adding an image to the chat input field in a chat before sending it off to a vision model. This PR only solves issues and does not cause any itself based on my testing concluded. ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. translations of the new items added in the last version have been carried out. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 08:33:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#63649