# Discourse AI: structured output response was not valid JSON

**URL:** https://meta.discourse.org/t/discourse-ai-structured-output-response-was-not-valid-json/408821
**Category:** Support
**Tags:** ai
**Created:** [July 29, 2026, 2:11pm UTC](https://meta.discourse.org/t/discourse-ai-structured-output-response-was-not-valid-json/408821 "2026-07-29T14:11:05Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![lilydjwg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilydjwg/32/515838_2.png) [@lilydjwg](https://meta.discourse.org/u/lilydjwg)
#### Post date: [July 29, 2026, 3:48pm UTC](https://meta.discourse.org/t/discourse-ai-structured-output-response-was-not-valid-json/408821/3 "2026-07-29T15:48:01Z")

</div>

> [@Falco](#):
>
> That is a warning, not an error.

Well, technically true, but it indicates a bug in the code. The fallback works so no error is raised, but it is better to fix the source instead of moving it to INFO level to cover up, isn’t it?

JSON allows line feed charaters as whitespace but doesn’t allow escape sequences outside strings; the escape function however escapes it. To fix it, you can change to escape only ASCII characters 0x0 to 0x1f inclusive according to the JSON spec. (I don’t know how to write it in Ruby so no PR.)

---

_[View the full topic](https://meta.discourse.org/t/discourse-ai-structured-output-response-was-not-valid-json/408821)._
