mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 14:39:31 -05:00
[PR #24777] [CLOSED] fix: prefer source_url for document citation links #115144
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/24777
Author: @DuncanSARapp
Created: 5/15/2026
Status: ❌ Closed
Base:
dev← Head:codex/source-url-citations📝 Commits (1)
023b1e7fix: prefer source url for document citations📊 Changes
7 files changed (+337 additions, -24 deletions)
View changed files
➕
backend/open_webui/retrieval/source.py(+95 -0)📝
backend/open_webui/retrieval/utils.py(+13 -1)📝
backend/open_webui/routers/retrieval.py(+13 -1)➕
backend/open_webui/test/retrieval/test_source.py(+148 -0)📝
src/lib/components/chat/Messages/Citations.svelte(+28 -4)📝
src/lib/components/chat/Messages/Citations/CitationModal.svelte(+39 -17)📝
src/lib/components/chat/Messages/ContentRenderer.svelte(+1 -1)📄 Description
Pull Request Checklist
Note to first-time contributors: A discussion has been opened before this PR: https://github.com/open-webui/open-webui/discussions/24773
Before submitting, make sure you've checked the following:
devbranch.source_urlonly as citation presentation metadata.dev, and contains no unrelated commits.fixprefix.Description
This PR updates citation URL resolution so API-uploaded documents can preserve their authoritative source URL.
When citation metadata includes a source URL, Open WebUI now prefers that URL for citation links before falling back to the internal file endpoint. This keeps current behavior for normal file uploads while improving API ingestion workflows where documents originate from another system.
No new dependencies are added.
Reproduction
Before this change:
{"source_url": "https://gitlab.example.com/group/project/-/blob/main/docs/spec.md"}Expected: the citation opens the provided
source_url.Actual: the citation can fall back to Open WebUI's internal file endpoint.
Changed
source_urlis absent or invalid.source_urlonly as a presentation hint for citation links.Testing
Tested locally with:
podman build --env NODE_OPTIONS=--max-old-space-size=4096 --build-arg USE_SLIM=true --build-arg BUILD_HASH=023b1e735 -t localhost/open-webui-source-url:source-url-citations .OLLAMA_BASE_URL=http://host.containers.internal:11434GET /health{"status": true}cd /app/backend && python -m pytest open_webui/test/retrieval/test_source.py37 passedhttpandhttpssource URLsjavascript:,data:,file:,blob:, andmailto:URLsDocumentation
source_urlwhen present.source_urlis absent or invalid.Security Considerations
source_urlis only used as a citation presentation hint.httpandhttpsURLs with a valid host are accepted.source_urlis never used for authorization, file lookup, deletion, backend fetches, or access decisions.rel="noopener noreferrer"when opened withtarget="_blank".source_urlare excluded from the Google favicon lookup used for regular URL citations.AI-assisted Code Note
This PR was AI-assisted, but the changes were manually reviewed and manually tested by the author. The implementation was verified in a running Open WebUI container, including the steps listed above.
Changelog Entry
Description
Added
Changed
Deprecated
Removed
Fixed
Security
source_urlare not added to the Google favicon lookup used for regular URL citations.Breaking Changes
Additional Information
dev.Screenshots or Videos
No screenshot included. This is citation metadata resolution behavior rather than a new UI surface.
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.