open-webui / open-webui/computer

bug: unguarded json.loads on streamed tool-call arguments crashes the request on empty/truncated JSON

Open
#252 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
569
Forks
79
PR merge metrics
No merged PRs in 30d

Description

bug: unguarded json.loads on streamed tool-call arguments crashes the request on empty/truncated JSON

Bug description

Providers occasionally stream empty or truncated tool-call argument JSON
(e.g. output cut off by token limits or an upstream hiccup). The unguarded
json.loads() on streamed arguments then raises JSONDecodeError, which
surfaces to the user as a raw error and aborts the in-flight step:

Error: Expecting value: line 1 column 1 (char 0)

This is provider-agnostic — any of the streaming providers can emit an empty
or truncated arguments payload.

Expected behavior

A malformed/empty streamed arguments payload should degrade gracefully, not
kill the request.

Suggested approach

Add a shared parse helper that:

  1. Parses strictly,
  2. Falls back to the existing lenient extract_json() helper,
  3. On total failure, raises a descriptive error naming the tool and including a payload snippet (instead of a bare JSONDecodeError).

Apply it to all streaming providers (Anthropic, OpenAI chat completions,
OpenAI Responses) and to Anthropic history replay, where a stale corrupt
payload in history should degrade to {} rather than breaking the current
request.

Environment
  • Latest main

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the shared extract_json() helper and the streaming argument parsing paths for Anthropic, OpenAI chat completions, OpenAI Responses, plus Anthropic history replay. Trace how empty or truncated payloads currently reach json.loads(), then verify that malformed streaming input produces a descriptive tool-specific error and corrupt history degrades to {} without aborting the request.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.