Skip to content

Kingy / AI Fix Finder

← All fixes

JSON is correct, but a Markdown fence breaks parsing

Check this fix ↓

Six retained Qwen3 outputs pass exact-answer validation after removing one enclosing Markdown fence. Seven other fenced answers still fail.

kingy tested

Tested repair · Qwen3 + JSON parser · llama.cpp build10809; exact GGUF revisions in evidence ZIP; retained-output replay in Python 3.14.0

Check this fix

Applies when
Python json.loads rejects a response beginning with ```json with JSONDecodeError: Expecting value: line 1 column 1 (char 0).
Change to inspect
Remove one enclosing Markdown fence only when it wraps the entire response, then parse and validate the answer again. Keep both the raw response and its original failed score.
Expected result
The September 21 replay found 13 whole-response fenced outputs among 36 retained attempts. Six matched their answer keys after unfencing; seven still contained wrong answers. Seven negative controls were rejected. No model was rerun and historical strict scores remain unchanged.
If it still fails
Keep the original failed output and check the conditions and verification steps below. Retained failed attempt: Three formatting-only failures for 0.6B and three for 1.7B remained failed in the original benchmark.

Tested or reviewed 2026-09-21. Verify the original task on your own version and settings; this case does not prove a universal fix.

Read the verification steps ↓ · Report your outcome ↓

Try the correction

Make this JSON parse.

Start with an original failed response, or paste a non-sensitive example. This runs in your browser; your text is not sent to Kingy.

Rejects duplicate keys and non-finite numbers. It removes one whole-response fence; it cannot correct invented or wrong values.

What happened

Symptom

Python json.loads rejects a response beginning with ```json with JSONDecodeError: Expecting value: line 1 column 1 (char 0).

Exact environment and tested conditions

Qwen3-0.6B-Q8_0 and Qwen3-1.7B-Q8_0 in the retained four-task JSON pilot

Correction

Remove one enclosing Markdown fence only when it wraps the entire response, then parse and validate the answer again. Keep both the raw response and its original failed score.

Result

The September 21 replay found 13 whole-response fenced outputs among 36 retained attempts. Six matched their answer keys after unfencing; seven still contained wrong answers. Seven negative controls were rejected. No model was rerun and historical strict scores remain unchanged.

What did not work

Three formatting-only failures for 0.6B and three for 1.7B remained failed in the original benchmark.

  1. Save the raw response. Confirm the entire trimmed response is a single ```json or ``` fenced block; the replay script rejects surrounding prose and embedded backticks.
  2. Remove only that opening line and final closing fence. Never extract a convenient object from a longer response.
  3. Parse with duplicate-key rejection via object_pairs_hook and nonstandard-number rejection via parse_constant and finite-float range checking via parse_float; json.loads defaults alone do not provide these checks.
  4. Compare the parsed result with the source answer, including keys, types, values and array order. In the retained test, boolean true cannot stand in for number 1.
  5. Fallback: if the response has prose, multiple blocks or wrong values, keep it failed. Obtain a new response or correct the task input, then validate independently; do not infer missing facts.
  6. Download the reproduction ZIP under Sources & limits to replay the 36 retained attempts and seven negative controls without calling a model.
Sources & limits

Small Qwen3 models: retained JSON pilot

Python JSON decoder: hooks, errors and compliance

September 21 Fix Finder reproduction scripts and results (ZIP)

Record checked 2026-09-21.

This is post-processing verified against retained output, not a retested prompting correction.

Do not strip arbitrary text, silently accept wrong values, or use an unknown answer key as proof.

The replay has known answer keys. In a real workflow, a valid JSON document still needs schema and source-fact checks; parsing success is insufficient.

The diagnostic accepts a narrow fence shape and caps response length at 100,000 characters. It is a reproducibility example, not a complete untrusted-input service.

This still happens?

Send the smallest example that reproduces it. Use a public, non-sensitive example; leave out account details, keys and private files.

Help improve this tool

Did this repair work for you?

About AI Fix Finder. Your self-reported outcome goes to Kingy’s private review queue; it is not an independently verified reproduction.

Your experience with AI Fix Finder
What happened?