[GH-ISSUE #16966] issue: better error handling for defective citation/source events from tools/pipes in Frontend #33644

Closed
opened 2026-04-25 07:32:37 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @Podden on GitHub (Aug 27, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/16966

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

0.6.25

Ollama Version (if applicable)

No response

Operating System

Ubuntu 22.04

Browser (if applicable)

No response

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

I'm experimenting with imported tools and pipes and sometimes there are malformed source/citation events (documentation on this is very vague, it just says "# Open WebUI Code Source (Citation) Object") and noticed that the frontend get's completly unresponsive and the conversations cant be opened anymore if there is a problematic citation or source (for example without "document" key.

Maybe defective citations can just be skipped while loading so I still can open the conversation?

Uncaught (in promise) TypeError: can't access property "forEach", S.document is undefined o Citations.svelte:54 update Citations.svelte:53 ln Component.js:144 Ra Citations.svelte:95 Bs ResponseMessage.svelte:853 xo ResponseMessage.svelte:849 Ys ResponseMessage.svelte:737 Df ResponseMessage.svelte:596 ln Component.js:148 nl ResponseMessage.svelte:567 bu Message.svelte:104 Ln Message.svelte:73 ku Message.svelte:52 ln Component.js:148 Iu Message.svelte:44 Xn Messages.svelte:431 $n Messages.svelte:425 Wu Messages.svelte:406 Gu Messages.svelte:402 ln Component.js:148 jc Messages.svelte:92 ice Chat.svelte:2292 sce Chat.svelte:2261 ae utils.js:165 Sa pane-group.svelte:44 ln Component.js:148 le pane.svelte:76 rce Chat.svelte:2219 ae utils.js:165 ja ctx.js:17 ln Component.js:148 ue pane-group.svelte:44 tce Chat.svelte:2185 p Chat.svelte:2159 Vt scheduler.js:119 vt scheduler.js:79 promise callback*wt scheduler.js:20 ee Component.js:81 ctx Component.js:139 Be Chat.svelte:172 update Chat.svelte:152 ln Component.js:144 T0e Chat.svelte:224 h Immutable ln Component.js:148 I +page.svelte:7 Re dom.js:1228 p root.svelte:57 p root.svelte:51 ue utils.js:203 p +layout.svelte:347 p +layout.svelte:284 p +layout.svelte:353 p +layout.svelte:276 Vt scheduler.js:119 vt scheduler.js:79 promise callback*wt scheduler.js:20 ee Component.js:81 ctx Component.js:139 $$set root.svelte:69 $set Component.js:507 W client.js:1595 Bn client.js:2383 Bn client.js:2274 Xn client.js:339 async* (index):123 promise callback* (index):122

Actual Behavior

OpenWebUI becomes completely unclickable until i refresh the page to a working conversation (or home screen)

Steps to Reproduce

Start a new Conversation, use a Tool or Pipe or Filter which does not create a correct source/citation object. Try to open the conversation again.

Logs & Screenshots

Uncaught (in promise) TypeError: can't access property "forEach", S.document is undefined
o Citations.svelte:54
update Citations.svelte:53
ln Component.js:144
Ra Citations.svelte:95
Bs ResponseMessage.svelte:853
xo ResponseMessage.svelte:849
Ys ResponseMessage.svelte:737
Df ResponseMessage.svelte:596
ln Component.js:148
nl ResponseMessage.svelte:567
bu Message.svelte:104
Ln Message.svelte:73
ku Message.svelte:52
ln Component.js:148
Iu Message.svelte:44
Xn Messages.svelte:431
$n Messages.svelte:425
Wu Messages.svelte:406
Gu Messages.svelte:402
ln Component.js:148
jc Messages.svelte:92
ice Chat.svelte:2292
sce Chat.svelte:2261
ae utils.js:165
Sa pane-group.svelte:44
ln Component.js:148
le pane.svelte:76
rce Chat.svelte:2219
ae utils.js:165
ja ctx.js:17
ln Component.js:148
ue pane-group.svelte:44
tce Chat.svelte:2185
p Chat.svelte:2159
Vt scheduler.js:119
vt scheduler.js:79
promise callbackwt scheduler.js:20
ee Component.js:81
ctx Component.js:139
Be Chat.svelte:172
update Chat.svelte:152
ln Component.js:144
T0e Chat.svelte:224
h Immutable
ln Component.js:148
I +page.svelte:7
Re dom.js:1228
p root.svelte:57
p root.svelte:51
ue utils.js:203
p +layout.svelte:347
p +layout.svelte:284
p +layout.svelte:353
p +layout.svelte:276
Vt scheduler.js:119
vt scheduler.js:79
promise callback
wt scheduler.js:20
ee Component.js:81
ctx Component.js:139
$$set root.svelte:69
$set Component.js:507
W client.js:1595
Bn client.js:2383
Bn client.js:2274
Xn client.js:339
async* (index):123
promise callback* (index):122

Additional Information

No response

Originally created by @Podden on GitHub (Aug 27, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/16966 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version 0.6.25 ### Ollama Version (if applicable) _No response_ ### Operating System Ubuntu 22.04 ### Browser (if applicable) _No response_ ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior I'm experimenting with imported tools and pipes and sometimes there are malformed source/citation events ([documentation ](https://docs.openwebui.com/features/plugin/events/) on this is very vague, it just says "# Open WebUI Code Source (Citation) Object") and noticed that the frontend get's completly unresponsive and the conversations cant be opened anymore if there is a problematic citation or source (for example without "document" key. Maybe defective citations can just be skipped while loading so I still can open the conversation? `Uncaught (in promise) TypeError: can't access property "forEach", S.document is undefined o Citations.svelte:54 update Citations.svelte:53 ln Component.js:144 Ra Citations.svelte:95 Bs ResponseMessage.svelte:853 xo ResponseMessage.svelte:849 Ys ResponseMessage.svelte:737 Df ResponseMessage.svelte:596 ln Component.js:148 nl ResponseMessage.svelte:567 bu Message.svelte:104 Ln Message.svelte:73 ku Message.svelte:52 ln Component.js:148 Iu Message.svelte:44 Xn Messages.svelte:431 $n Messages.svelte:425 Wu Messages.svelte:406 Gu Messages.svelte:402 ln Component.js:148 jc Messages.svelte:92 ice Chat.svelte:2292 sce Chat.svelte:2261 ae utils.js:165 Sa pane-group.svelte:44 ln Component.js:148 le pane.svelte:76 rce Chat.svelte:2219 ae utils.js:165 ja ctx.js:17 ln Component.js:148 ue pane-group.svelte:44 tce Chat.svelte:2185 p Chat.svelte:2159 Vt scheduler.js:119 vt scheduler.js:79 promise callback*wt scheduler.js:20 ee Component.js:81 ctx Component.js:139 Be Chat.svelte:172 update Chat.svelte:152 ln Component.js:144 T0e Chat.svelte:224 h Immutable ln Component.js:148 I +page.svelte:7 Re dom.js:1228 p root.svelte:57 p root.svelte:51 ue utils.js:203 p +layout.svelte:347 p +layout.svelte:284 p +layout.svelte:353 p +layout.svelte:276 Vt scheduler.js:119 vt scheduler.js:79 promise callback*wt scheduler.js:20 ee Component.js:81 ctx Component.js:139 $$set root.svelte:69 $set Component.js:507 W client.js:1595 Bn client.js:2383 Bn client.js:2274 Xn client.js:339 async* (index):123 promise callback* (index):122 ` ### Actual Behavior OpenWebUI becomes completely unclickable until i refresh the page to a working conversation (or home screen) ### Steps to Reproduce Start a new Conversation, use a Tool or Pipe or Filter which does not create a correct source/citation object. Try to open the conversation again. ### Logs & Screenshots Uncaught (in promise) TypeError: can't access property "forEach", S.document is undefined o Citations.svelte:54 update Citations.svelte:53 ln Component.js:144 Ra Citations.svelte:95 Bs ResponseMessage.svelte:853 xo ResponseMessage.svelte:849 Ys ResponseMessage.svelte:737 Df ResponseMessage.svelte:596 ln Component.js:148 nl ResponseMessage.svelte:567 bu Message.svelte:104 Ln Message.svelte:73 ku Message.svelte:52 ln Component.js:148 Iu Message.svelte:44 Xn Messages.svelte:431 $n Messages.svelte:425 Wu Messages.svelte:406 Gu Messages.svelte:402 ln Component.js:148 jc Messages.svelte:92 ice Chat.svelte:2292 sce Chat.svelte:2261 ae utils.js:165 Sa pane-group.svelte:44 ln Component.js:148 le pane.svelte:76 rce Chat.svelte:2219 ae utils.js:165 ja ctx.js:17 ln Component.js:148 ue pane-group.svelte:44 tce Chat.svelte:2185 p Chat.svelte:2159 Vt scheduler.js:119 vt scheduler.js:79 promise callback*wt scheduler.js:20 ee Component.js:81 ctx Component.js:139 Be Chat.svelte:172 update Chat.svelte:152 ln Component.js:144 T0e Chat.svelte:224 h Immutable ln Component.js:148 I +page.svelte:7 Re dom.js:1228 p root.svelte:57 p root.svelte:51 ue utils.js:203 p +layout.svelte:347 p +layout.svelte:284 p +layout.svelte:353 p +layout.svelte:276 Vt scheduler.js:119 vt scheduler.js:79 promise callback*wt scheduler.js:20 ee Component.js:81 ctx Component.js:139 $$set root.svelte:69 $set Component.js:507 W client.js:1595 Bn client.js:2383 Bn client.js:2274 Xn client.js:339 async* (index):123 promise callback* (index):122 ### Additional Information _No response_
GiteaMirror added the bug label 2026-04-25 07:32:37 -05:00
Author
Owner

@rgaricano commented on GitHub (Aug 27, 2025):

For reference,
replace?
https://github.com/open-webui/open-webui/blob/1db8dec4f52fc0fa8f8f7bfbb8ea5bde41fee17d/src/lib/components/chat/Messages/Citations.svelte#L58
by source.document?.forEach((document, index) => {

<!-- gh-comment-id:3228393324 --> @rgaricano commented on GitHub (Aug 27, 2025): For reference, replace? https://github.com/open-webui/open-webui/blob/1db8dec4f52fc0fa8f8f7bfbb8ea5bde41fee17d/src/lib/components/chat/Messages/Citations.svelte#L58 by `source.document?.forEach((document, index) => { `
Author
Owner

@Podden commented on GitHub (Aug 27, 2025):

Enough for me.

Is there some kind of validator on the tool/function loading side? Maybe it's better to just dont allow tools with wrong event payloads.

I'll make a PR for the docs in the next days to clear up what the payload of source/citation should contain.

<!-- gh-comment-id:3229528772 --> @Podden commented on GitHub (Aug 27, 2025): Enough for me. Is there some kind of validator on the tool/function loading side? Maybe it's better to just dont allow tools with wrong event payloads. I'll make a PR for the docs in the next days to clear up what the payload of source/citation should contain.
Author
Owner

@rgaricano commented on GitHub (Aug 27, 2025):

Yes, there are some validators, but always can be increased ;)

For Reference,

Tool Validator

  • Payload validation after the module loading but before storing the tool

https://github.com/open-webui/open-webui/blob/1db8dec4f52fc0fa8f8f7bfbb8ea5bde41fee17d/backend/open_webui/routers/tools.py#L222-L223

        specs = get_tool_specs(TOOLS[form_data.id])  
          
        # NEW: Validate tool specs and event payloads  
        validate_tool_event_payloads(specs, tool_module)  
          
        tools = Tools.insert_new_tool(user.id, form_data, specs)  

function, add in e.g. L232

def validate_tool_event_payloads(specs: list[dict], tool_module: object) -> None:  
    """  
    Validates that tool specs have proper event payload structures.  
    Raises HTTPException if validation fails.  
    """  
    for spec in specs:  
        # Validate required spec structure  
        if not spec.get("name"):  
            raise HTTPException(  
                status_code=400,   
                detail=f"Tool spec missing required 'name' field"  
            )  
          
        if not spec.get("parameters"):  
            raise HTTPException(  
                status_code=400,  
                detail=f"Tool '{spec.get('name')}' missing parameters definition"  
            )  
          
        # Validate parameters structure  
        params = spec.get("parameters", {})  
        if params.get("type") != "object":  
            raise HTTPException(  
                status_code=400,  
                detail=f"Tool '{spec.get('name')}' parameters must be of type 'object'"  
            )  
          
        # Validate properties exist and are properly structured  
        properties = params.get("properties", {})  
        for prop_name, prop_def in properties.items():  
            if not isinstance(prop_def, dict):  
                raise HTTPException(  
                    status_code=400,  
                    detail=f"Tool '{spec.get('name')}' property '{prop_name}' must be an object"  
                )  
              
            if not prop_def.get("type"):  
                raise HTTPException(  
                    status_code=400,  
                    detail=f"Tool '{spec.get('name')}' property '{prop_name}' missing type definition"  
                )  
          
        # Validate that required parameters exist in properties  
        required = params.get("required", [])  
        for req_param in required:  
            if req_param not in properties:  
                raise HTTPException(  
                    status_code=400,  
                    detail=f"Tool '{spec.get('name')}' required parameter '{req_param}' not found in properties"  
                )
  • Validation in OpenAPI to tool payload conversion, plus function for validate single tool

https://github.com/open-webui/open-webui/blob/1db8dec4f52fc0fa8f8f7bfbb8ea5bde41fee17d/backend/open_webui/utils/tools.py#L468-L471

                validate_single_tool_payload(tool)  
                tool_payload.append(tool)  
  
    return tool_payload  
  
def validate_single_tool_payload(tool: dict) -> None:  
    """Validates a single tool payload structure"""  
    if not tool.get("name"):  
        raise ValueError("Tool payload missing required 'name' field")  
      
    if not isinstance(tool.get("parameters"), dict):  
        raise ValueError(f"Tool '{tool.get('name')}' parameters must be a dictionary")  
      
    params = tool.get("parameters", {})  
    if params.get("type") != "object":  
        raise ValueError(f"Tool '{tool.get('name')}' parameters type must be 'object'")  
      
    # Validate properties structure  
    properties = params.get("properties", {})  
    if not isinstance(properties, dict):  
        raise ValueError(f"Tool '{tool.get('name')}' properties must be a dictionary")
  • Enhance the tool server data fetching tools to validate OpenAPI specs

https://github.com/open-webui/open-webui/blob/1db8dec4f52fc0fa8f8f7bfbb8ea5bde41fee17d/backend/open_webui/utils/tools.py#L535-L542

    data = {  
        "openapi": res,  
        "info": res.get("info", {}),  
        "specs": convert_openapi_to_tool_payload(res),  
    }  
      
    # NEW: Validate the converted specs  
    for spec in data["specs"]:  
        validate_single_tool_payload(spec)  
  
    log.info(f"Fetched and validated data: {data}")  
    return data
  • add client-side validation in the tool creation form

https://github.com/open-webui/open-webui/blob/1db8dec4f52fc0fa8f8f7bfbb8ea5bde41fee17d/src/routes/(app)/workspace/tools/create/%2Bpage.svelte#L17-L20

const saveHandler = async (data) => {  
    console.log(data);  
  
    // NEW: Client-side validation before sending to backend  
    try {  
        validateToolData(data);  
    } catch (error) {  
        toast.error(`Validation failed: ${error.message}`);  
        return;  
    }  
  
    const manifest = extractFrontmatter(data.content);  

XXX

<!-- gh-comment-id:3229638997 --> @rgaricano commented on GitHub (Aug 27, 2025): Yes, there are some validators, but always can be increased ;) For Reference, ### Tool Validator - **Payload validation after the module loading but before storing the tool** https://github.com/open-webui/open-webui/blob/1db8dec4f52fc0fa8f8f7bfbb8ea5bde41fee17d/backend/open_webui/routers/tools.py#L222-L223 ``` specs = get_tool_specs(TOOLS[form_data.id]) # NEW: Validate tool specs and event payloads validate_tool_event_payloads(specs, tool_module) tools = Tools.insert_new_tool(user.id, form_data, specs) ``` function, add in e.g. L232 ``` def validate_tool_event_payloads(specs: list[dict], tool_module: object) -> None: """ Validates that tool specs have proper event payload structures. Raises HTTPException if validation fails. """ for spec in specs: # Validate required spec structure if not spec.get("name"): raise HTTPException( status_code=400, detail=f"Tool spec missing required 'name' field" ) if not spec.get("parameters"): raise HTTPException( status_code=400, detail=f"Tool '{spec.get('name')}' missing parameters definition" ) # Validate parameters structure params = spec.get("parameters", {}) if params.get("type") != "object": raise HTTPException( status_code=400, detail=f"Tool '{spec.get('name')}' parameters must be of type 'object'" ) # Validate properties exist and are properly structured properties = params.get("properties", {}) for prop_name, prop_def in properties.items(): if not isinstance(prop_def, dict): raise HTTPException( status_code=400, detail=f"Tool '{spec.get('name')}' property '{prop_name}' must be an object" ) if not prop_def.get("type"): raise HTTPException( status_code=400, detail=f"Tool '{spec.get('name')}' property '{prop_name}' missing type definition" ) # Validate that required parameters exist in properties required = params.get("required", []) for req_param in required: if req_param not in properties: raise HTTPException( status_code=400, detail=f"Tool '{spec.get('name')}' required parameter '{req_param}' not found in properties" ) ``` - **Validation in OpenAPI to tool payload conversion, plus function for validate single tool** https://github.com/open-webui/open-webui/blob/1db8dec4f52fc0fa8f8f7bfbb8ea5bde41fee17d/backend/open_webui/utils/tools.py#L468-L471 ``` validate_single_tool_payload(tool) tool_payload.append(tool) return tool_payload def validate_single_tool_payload(tool: dict) -> None: """Validates a single tool payload structure""" if not tool.get("name"): raise ValueError("Tool payload missing required 'name' field") if not isinstance(tool.get("parameters"), dict): raise ValueError(f"Tool '{tool.get('name')}' parameters must be a dictionary") params = tool.get("parameters", {}) if params.get("type") != "object": raise ValueError(f"Tool '{tool.get('name')}' parameters type must be 'object'") # Validate properties structure properties = params.get("properties", {}) if not isinstance(properties, dict): raise ValueError(f"Tool '{tool.get('name')}' properties must be a dictionary") ``` - **Enhance the tool server data fetching tools to validate OpenAPI specs** https://github.com/open-webui/open-webui/blob/1db8dec4f52fc0fa8f8f7bfbb8ea5bde41fee17d/backend/open_webui/utils/tools.py#L535-L542 ``` data = { "openapi": res, "info": res.get("info", {}), "specs": convert_openapi_to_tool_payload(res), } # NEW: Validate the converted specs for spec in data["specs"]: validate_single_tool_payload(spec) log.info(f"Fetched and validated data: {data}") return data ``` - **add client-side validation in the tool creation form** https://github.com/open-webui/open-webui/blob/1db8dec4f52fc0fa8f8f7bfbb8ea5bde41fee17d/src/routes/(app)/workspace/tools/create/%2Bpage.svelte#L17-L20 ``` const saveHandler = async (data) => { console.log(data); // NEW: Client-side validation before sending to backend try { validateToolData(data); } catch (error) { toast.error(`Validation failed: ${error.message}`); return; } const manifest = extractFrontmatter(data.content); ``` XXX
Author
Owner

@tjbck commented on GitHub (Aug 27, 2025):

dca7ce9420

<!-- gh-comment-id:3230146661 --> @tjbck commented on GitHub (Aug 27, 2025): dca7ce942009f4990b4843fb5fb9b7249ff59659
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#33644