Translation silently truncated when JSON stream parsing breaks (no error raised)

Adding a data point to this — we’re seeing what looks like the same underlying
mechanism, but manifesting differently.

Observed on: Discourse core + discourse-ai, LLM: GPT-5.1 via OpenAI (custom API connection, not a seeded model).

Reproduction evidence

Same source post (Russian, ~2000 chars, headers/bold/bullet lists/links),
translated into multiple locales via native AI translation:

  • Polish (pl): the embedded image markdown lost its structure — went from
    ![alt text|690x460](upload://...) to a malformed link missing the !
    prefix and the | separator, with the alt text and dimensions run
    together as plain text. Rendered as a clickable link instead of an
    embedded image.
  • Ukrainian (uk): literal \n\n sequences appear as plain text throughout
    the entire post, in place of paragraph breaks. The image markdown in this
    same translation was intact — so the corruption isn’t tied to one fixed
    symptom, it varies by run.

Unlike the truncation described above, our case shows no missing content —
the full text is present, but with corrupted escape sequences / markdown
syntax rather than a shortened output. Different provider (OpenAI vs Google
here), different symptom (corruption vs truncation), same suspected root:
StructuredOutput#read_buffered_property falling back to
BestEffortJsonParser#extract_key, which doesn’t unescape JSON string
sequences (\n stays literal) and appears to also mishandle special
characters adjacent to markdown syntax when the fallback triggers mid-parse.

No errors in Sidekiq or Rails logs on our side either — same silent-failure
behavior.

1 Like