fix(webui): send chat images as data URLs (fix HTTP 500 on image send) - #2338
Open
subin9 wants to merge 1 commit into
Open
fix(webui): send chat images as data URLs (fix HTTP 500 on image send)#2338subin9 wants to merge 1 commit into
subin9 wants to merge 1 commit into
Conversation
The UI uploaded images to /api/upload_image and sent back the returned
relative `uploads/<uuid>` URL as image_url.url. /v1/chat/completions
resolves sources under the ServerRequest policy, which only accepts
http/https/data URLs, so Url::parse("uploads/...") failed with
RelativeUrlWithoutBase -> HTTP 500 "invalid image source ... relative
url without a base". The v1 API worked because callers pass data/http
URLs. Encode picked files as data: URLs client-side instead (also fixes
videos, which shared the same path).
Code Metrics Report━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Language Files Lines Code Comments Blanks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ C Header 23 4454 3116 790 548 CSS 3 282 252 6 24 CUDA 119 23681 19217 1704 2760 Dockerfile 1 35 19 9 7 HTML 2 27 27 0 0 JavaScript 3 577 562 12 3 Jinja2 7 694 656 5 33 JSON 27 15864 15861 0 3 Makefile 1 18 16 0 2 MDX 36 5901 0 4327 1574 Metal Shading Lan| 37 14287 11284 1136 1867 PowerShell 1 656 570 31 55 Python 151 12284 10191 484 1609 Shell 3 1062 843 117 102 Plain Text 53 10687 0 9209 1478 TOML 28 1368 1189 39 140 TypeScript 11 1641 1404 66 171 YAML 3 25 23 2 0 ───────────────────────────────────────────────────────────────────────────────── Jupyter Notebooks 3 122 83 23 16 |- Markdown 1 60 30 22 8 |- Python 1 122 113 1 8 (Total) 304 226 46 32 ───────────────────────────────────────────────────────────────────────────────── Markdown 273 11726 0 8736 2990 |- BASH 23 295 217 46 32 |- Dockerfile 2 5 5 0 0 |- JSON 6 289 289 0 0 |- PowerShell 1 1 1 0 0 |- Python 135 7239 6021 310 908 |- Rust 62 3820 2838 388 594 |- TOML 7 77 65 0 12 (Total) 23452 9436 9480 4536 ───────────────────────────────────────────────────────────────────────────────── Rust 674 299702 267081 5872 26749 |- Markdown 413 9761 452 8126 1183 (Total) 309463 267533 13998 27932 ───────────────────────────────────────────────────────────────────────────────── Svelte 19 1969 1826 51 92 |- CSS 1 4 4 0 0 |- JavaScript 19 921 767 25 129 (Total) 2894 2597 76 221 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Total 1478 429656 345022 41537 43097 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
subin9
force-pushed
the
fix/webui-image-dataurl
branch
from
July 11, 2026 01:51
6b6dd0b to
325c8e3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sending an image from the built-in web UI (
/ui) failed with HTTP 500invalid image source, expected http https or data url: relative url without a base, while the same image through/v1/chat/completionsworked. Closes #2336.Cause
The UI uploaded the picked image to
/api/upload_image, which saves it under the cache dir and returns a relative URL (uploads/<uuid>.png). The UI stored that string and sent it back asimage_url.urlto/v1/chat/completions, which resolves image sources under theServerRequestmedia policy - accepting onlyhttp/https/dataURLs.Url::parse("uploads/<uuid>.png")fails withRelativeUrlWithoutBase, producing the 500. The v1 API worked because callers pass adata:/http(s)URL.Fix
Encode picked files as
data:URLs client-side (viaFileReader.readAsDataURL) and send those - exactly what the working v1 path sends - instead of round-tripping through the upload endpoint. This also fixes the identical relative-URL failure for videos, and works for display-on-reload since a data URL is self-contained.