discourse-ai/spec
Roman Rizzi d72ad84f8f
FIX: Retry parsing escaped inner JSON to handle control chars. (#1357)
The structured output JSON comes embedded inside the API response, which is also a JSON. Since we have to parse the response to process it, any control characters inside the structured output are unescaped into regular characters, leading to invalid JSON and breaking during parsing. This change adds a retry mechanism that escapes
the string again if parsing fails, preventing the parser from breaking on malformed input and working around this issue.

For example:

```
  original = '{ "a": "{\\"key\\":\\"value with \\n newline\\"}" }'
  JSON.parse(original) => { "a" => "{\"key\":\"value with \n newline\"}" }
  # At this point, the inner JSON string contains an actual newline.
```
2025-05-21 11:25:59 -03:00
..
configuration
db/migrate
fabricators
fixtures FEATURE: enforce jpg/png for all images (#1309) 2025-05-05 17:46:37 +10:00
jobs DEV: Use structured responses for summaries (#1252) 2025-05-06 10:09:39 -03:00
lib FIX: Retry parsing escaped inner JSON to handle control chars. (#1357) 2025-05-21 11:25:59 -03:00
models FEATURE: Examples support for personas. (#1334) 2025-05-13 10:06:16 -03:00
reports
requests FEATURE: Examples support for personas. (#1334) 2025-05-13 10:06:16 -03:00
serializers
services DEV: Use structured responses for summaries (#1252) 2025-05-06 10:09:39 -03:00
shared
support
system DEV: rewrites artifact spec with capybara waiters (#1347) 2025-05-20 07:27:15 +10:00
tasks DEV: Rename spec (#1344) 2025-05-16 09:40:08 +01:00
plugin_helper.rb
plugin_spec.rb