[GH-ISSUE #20991] issue: Empty embeds attribute renders as {} in tool calls UI #34882

Closed
opened 2026-04-25 09:03:42 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @cannontrodder on GitHub (Jan 28, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/20991

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items.
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

v0.7.2

Ollama Version (if applicable)

N/A (using AWS Bedrock via LiteLLM)

Operating System

Kubernetes (Linux containers)

Browser (if applicable)

Chrome, Safari

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of Open WebUI.
  • I have included the browser console logs.
  • I have included relevant code analysis.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation.

Expected Behavior

When a tool call completes without any embeds (e.g., image generation tools), the UI should cleanly display the tool result without any spurious rendered content.

Actual Behavior

An empty object {} is rendered in a red box in the UI after tool calls that don't return embeds. The browser console shows:

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Root Cause Analysis

In backend/open_webui/utils/middleware.py at line 2388:

tool_result_embeds = result.get("embeds", "")
tool_calls_display_content = f'...embeds="{html.escape(json.dumps(tool_result_embeds))}"...'

When embeds is missing from the result:

  1. Default value is "" (empty string)
  2. json.dumps("")'""'
  3. html.escape('""')'""'
  4. HTML attribute becomes embeds=""""

In the frontend (Collapsible.svelte line 96):

{@const embeds = parseJSONString(decode(attributes?.embeds ?? ''))}
  1. decode('""')""
  2. JSON.parse('""')"" (empty string, not array)
  3. The check if embeds && Array.isArray(embeds) fails
  4. Empty string gets rendered as {}

Steps to Reproduce

  1. Use any tool that doesn't return embeds (e.g., built-in image generation)
  2. Send a prompt like "Generate an image of a cat"
  3. Wait for the tool to execute
  4. Observe {} rendered in the UI and JSON parse error in console

Proposed Fix

# Change default from "" to []
tool_result_embeds = result.get("embeds", [])

# Only include embeds attribute when non-empty
embeds_attr = f' embeds="{html.escape(json.dumps(tool_result_embeds))}"' if tool_result_embeds else ''

I have a PR ready with this fix.

Logs & Screenshots

Browser console error:

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Stored message content showing the problematic attribute:

<details type="tool_calls" ... embeds="&quot;&quot;">
Originally created by @cannontrodder on GitHub (Jan 28, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/20991 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items. - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version v0.7.2 ### Ollama Version (if applicable) N/A (using AWS Bedrock via LiteLLM) ### Operating System Kubernetes (Linux containers) ### Browser (if applicable) Chrome, Safari ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of Open WebUI. - [x] I have included the browser console logs. - [x] I have included relevant code analysis. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. ### Expected Behavior When a tool call completes without any embeds (e.g., image generation tools), the UI should cleanly display the tool result without any spurious rendered content. ### Actual Behavior An empty object `{}` is rendered in a red box in the UI after tool calls that don't return embeds. The browser console shows: ``` SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data ``` ### Root Cause Analysis In `backend/open_webui/utils/middleware.py` at line 2388: ```python tool_result_embeds = result.get("embeds", "") tool_calls_display_content = f'...embeds="{html.escape(json.dumps(tool_result_embeds))}"...' ``` When `embeds` is missing from the result: 1. Default value is `""` (empty string) 2. `json.dumps("")` → `'""'` 3. `html.escape('""')` → `'&quot;&quot;'` 4. HTML attribute becomes `embeds="&quot;&quot;"` In the frontend (`Collapsible.svelte` line 96): ```javascript {@const embeds = parseJSONString(decode(attributes?.embeds ?? ''))} ``` 1. `decode('&quot;&quot;')` → `""` 2. `JSON.parse('""')` → `""` (empty string, not array) 3. The check `if embeds && Array.isArray(embeds)` fails 4. Empty string gets rendered as `{}` ### Steps to Reproduce 1. Use any tool that doesn't return embeds (e.g., built-in image generation) 2. Send a prompt like "Generate an image of a cat" 3. Wait for the tool to execute 4. Observe `{}` rendered in the UI and JSON parse error in console ### Proposed Fix ```python # Change default from "" to [] tool_result_embeds = result.get("embeds", []) # Only include embeds attribute when non-empty embeds_attr = f' embeds="{html.escape(json.dumps(tool_result_embeds))}"' if tool_result_embeds else '' ``` I have a PR ready with this fix. ### Logs & Screenshots Browser console error: ``` SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data ``` Stored message content showing the problematic attribute: ```html <details type="tool_calls" ... embeds="&quot;&quot;"> ```
Author
Owner

@cannontrodder commented on GitHub (Jan 28, 2026):

Fix submitted in #20993

<!-- gh-comment-id:3810886713 --> @cannontrodder commented on GitHub (Jan 28, 2026): Fix submitted in #20993
Author
Owner

@cannontrodder commented on GitHub (Jan 28, 2026):

PR #20993 is now in draft mode. I'll be testing it locally shortly and will update once I've verified the fix works as expected.

<!-- gh-comment-id:3810899605 --> @cannontrodder commented on GitHub (Jan 28, 2026): PR #20993 is now in draft mode. I'll be testing it locally shortly and will update once I've verified the fix works as expected.
Author
Owner

@cannontrodder commented on GitHub (Jan 28, 2026):

Resubmitted as #20996 with a clean single commit (rebased and squashed as requested).

<!-- gh-comment-id:3811533393 --> @cannontrodder commented on GitHub (Jan 28, 2026): Resubmitted as #20996 with a clean single commit (rebased and squashed as requested).
Author
Owner

@cannontrodder commented on GitHub (Jan 28, 2026):

@Classic298 Resubmitted as #20996 with a clean single commit as requested. Ready for review when you get a chance.

<!-- gh-comment-id:3811540769 --> @cannontrodder commented on GitHub (Jan 28, 2026): @Classic298 Resubmitted as #20996 with a clean single commit as requested. Ready for review when you get a chance.
Author
Owner

@cannontrodder commented on GitHub (Jan 28, 2026):

Closing - the symptoms we observed were caused by a WAF configuration issue in our infrastructure, not an upstream bug. The 403 response from the WAF was being parsed as JSON, causing the error. Apologies for the noise.

<!-- gh-comment-id:3812018298 --> @cannontrodder commented on GitHub (Jan 28, 2026): Closing - the symptoms we observed were caused by a WAF configuration issue in our infrastructure, not an upstream bug. The 403 response from the WAF was being parsed as JSON, causing the error. Apologies for the noise.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#34882