Known issues
This page records known behavior that may affect integrations. Each issue includes examples and a mitigation you can apply while handling model output.
JSON output may include a Markdown code fence
Diffusion generation can occasionally wrap an otherwise valid JSON object in a
Markdown json code fence. In some responses, the three opening backticks are
missing but the json label and closing backticks remain.
Examples
With the opening fence:
```json
{"name":"Priya","intent":"trial"}
```
With the opening backticks missing:
json
{"name":"Priya","intent":"trial"}
```
Mitigation
Before parsing a response that should be JSON, remove the wrapper only when the entire output has one of the two prefixes above and a closing fence on its own final line. Then parse and validate the result against your expected schema. Do not use a generic character trim: that can alter legitimate JSON or string values.
- cURL / shell
- Python
- JavaScript
content=$(jq -r '.choices[0].message.content' response.json)
cleaned=$(
printf '%s' "$content" |
perl -0pe 's/\A(?:```json|json)[ \t]*\r?\n(.*)\r?\n```[ \t]*(?:\r?\n)?\z/$1/s'
)
printf '%s\n' "$cleaned" | jq .
from json import loads
from re import compile
FENCE_SHAPED = compile(
r"\A(?:```json|json)[ \t]*\r?\n(?P<body>[\s\S]*?)\r?\n```[ \t]*(?:\r?\n)?\Z"
)
def strip_json_fence(content: str) -> str:
match = FENCE_SHAPED.fullmatch(content)
return match.group("body") if match else content
value = loads(strip_json_fence(content))
const fenceShaped = /^(?:```json|json)[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t]*(?:\r?\n)?$/;
function stripJsonFence(content) {
const match = content.match(fenceShaped);
return match ? match[1] : content;
}
const value = JSON.parse(stripJsonFence(content));
If parsing or schema validation still fails, follow the bounded retry and fallback guidance in Prompt engineering.