fix(retrieval): report why a URL could not be read instead of blaming the knowledge base (#28362)
Fetching a URL and saving it were reported as one thing. Everything from reading the URL to writing the vector database sat inside a single try, whose handler blamed the knowledge base, so a page that could not be fetched, parsed or resolved was reported as a knowledge base error even though nothing had reached the knowledge base yet. Reading the URL now has its own handler that names the URL, and the knowledge base message is left to the step that actually touches it. When YouTube refused a transcript the reason was discarded earlier still: the loader caught the error, logged it, and returned an empty document list, so the empty result failed downstream and even the salvageable explanation was gone before a message was produced. The loader now raises YoutubeTranscriptError carrying a readable reason, mapped from the transcript library's own exception types. Blocked requests mention that a proxy can be configured, and disabled, age restricted, unavailable and missing language cases each say what actually happened. URLs that attach successfully are unaffected.
This commit is contained in:
2 files changed
+50
-5
No files matched your search
@@ -66,7 +66,7 @@ from open_webui.models.knowledge import Knowledges
|
||||
from open_webui.models.config import Config
|
||||
|
||||
# Document loaders
|
||||
from open_webui.retrieval.loaders.youtube import YoutubeLoader
|
||||
from open_webui.retrieval.loaders.youtube import YoutubeLoader, YoutubeTranscriptError
|
||||
from open_webui.retrieval.utils import (
|
||||
build_loader_from_config,
|
||||
get_loader_config,
|
||||
@@ -2336,8 +2336,25 @@ async def process_web(
|
||||
user=Depends(get_verified_user),
|
||||
):
|
||||
config = await get_retrieval_config()
|
||||
|
||||
try:
|
||||
content, docs = await get_content_from_url(request, form_data.url)
|
||||
except HTTPException:
|
||||
raise
|
||||
except YoutubeTranscriptError as e:
|
||||
log.warning('YouTube transcript unavailable for %s: %s', form_data.url, e)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=str(e),
|
||||
)
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=ERROR_MESSAGES.DEFAULT(e, f'Could not read content from {form_data.url}'),
|
||||
)
|
||||
|
||||
try:
|
||||
log.debug('text_content: %s', content)
|
||||
|
||||
if process:
|
||||
|
||||
Reference in new issue
Block a user