[GH-ISSUE #2467] [Bug]: json_object silently discards elements from array-root output #1007

Closed
opened 2026-11-04 01:47:40 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @bettercallcaleb on GitHub (Oct 14, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2467

What happened

With response_format: {"type":"json_object"}, an array-root model response can be accepted as a successful JSON object. _extract_json() selects the first balanced {...} inside the array and drops the remaining elements.

Reproduced on unmodified main (296b59d):

python3 - <<'PY'
from serve.structured import _ObjectOnly, validated_json
raw = '[{"answer":1},{"answer":2}]'
print(validated_json(raw, _ObjectOnly(), "stop"))
PY

Actual: {"answer":1}. The mock HTTP endpoint also returned 200 with that truncated object.

Expected: reject an array-root response with structured_output_failed (HTTP 502 for non-streaming requests), not silently reinterpret it as an object. Existing support for an object inside prose or a Markdown code fence (#762) should remain intact.

Strata version, GPU, OS

main at 296b59d · Ubuntu 24.04 LTS · Python 3.12 · GPU not used (parser-only and MockEngine HTTP reproduction).

Originally created by @bettercallcaleb on GitHub (Oct 14, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2467 ### What happened With `response_format: {"type":"json_object"}`, an array-root model response can be accepted as a successful JSON object. `_extract_json()` selects the first balanced `{...}` inside the array and drops the remaining elements. Reproduced on unmodified `main` (`296b59d`): ```bash python3 - <<'PY' from serve.structured import _ObjectOnly, validated_json raw = '[{"answer":1},{"answer":2}]' print(validated_json(raw, _ObjectOnly(), "stop")) PY ``` Actual: `{"answer":1}`. The mock HTTP endpoint also returned 200 with that truncated object. Expected: reject an array-root response with `structured_output_failed` (HTTP 502 for non-streaming requests), not silently reinterpret it as an object. Existing support for an object inside prose or a Markdown code fence (#762) should remain intact. ### Strata version, GPU, OS `main` at `296b59d` · Ubuntu 24.04 LTS · Python 3.12 · GPU not used (parser-only and MockEngine HTTP reproduction).
Author
Owner

@qiuzan2001 commented on GitHub (Oct 15, 2026):

Reproduced on Linux with main 296b59d2: serve.structured.validated_json('[{"answer":1},{"answer":2}]', _ObjectOnly(), 'stop') returns '{"answer":1}', the second element silently dropped. On open PR #2469 the same call raises StructuredOutputError ... the answer is not a JSON object, an object after prose ('Here: {"answer":1}') is still extracted, and serve/test_structured.py passes.

<!-- gh-comment-id:6184263968 --> @qiuzan2001 commented on GitHub (Oct 15, 2026): Reproduced on Linux with main 296b59d2: `serve.structured.validated_json('[{"answer":1},{"answer":2}]', _ObjectOnly(), 'stop')` returns `'{"answer":1}'`, the second element silently dropped. On open PR #2469 the same call raises `StructuredOutputError ... the answer is not a JSON object`, an object after prose (`'Here: {"answer":1}'`) is still extracted, and `serve/test_structured.py` passes.
Author
Owner

@Niko1221 commented on GitHub (Oct 19, 2026):

Thanks for taking the time to report this.

We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6271077583 --> @Niko1221 commented on GitHub (Oct 19, 2026): Thanks for taking the time to report this. We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1007
No description provided.