The /questions API method returns wrong markdown when the last revisions were made by a suggested edit improved in the review queue. This event leads to two revisions (one for the suggested edit and one for the final version) and the first one is used for the markdown and the second one for the rendered post body.

Consider this Bricks question.
The last edit was made during a Suggested Edits review, where the reviewer removed the direct imgur link between the asterisks.
The /questions API method returns the current version of the question (revision 5) in the body field, but the markdown of the suggested edit (revision 4) in the body_markdown field.

Live demo:

result of API call

Another example is this Meta Stack Exchange question, though it could be edited again by the time you see it. Live demo:

result of API call

  • Confirmed. And in hindsight might explain some weirdness I had on a project I abandoned. Also, unchanged in version 2.3. Commented Jan 5, 2019 at 17:57

1 Answer 1


This was an old, old bug: a bit of logic assumes that revisions can be ordered by their creation date. This is not true for Improved edits, as both the suggested edit and subsequent Improvement share the same date... So you'd get the wrong markdown.

I've resolved this by falling back on ID to order, which is how we do it most other places. This may not always work reliably in the case of edit collisions however (two independent revisions being submitted simultaneously) - but, the results of such things tend to be unpredictable anyway.

  • 1
    Yeah, I thought it was something like that. Thanks a lot for fixing this (and numerous other bugs during this week)!
    – Glorfindel
    Commented Jan 8, 2019 at 20:45
  • It's definitely fixed for the two cases I mentioned, but here is a case that still doesn't work: api.stackexchange.com/2.2/answers/… Any idea?
    – Glorfindel
    Commented Jan 10, 2019 at 9:46
  • Yeah - there are two other places where functionally the same code lives and I didn't hit them, @Glorfindel. Shame on me for trying to browse the repository on my phone! I'll try & hit the rest of them soon.
    – Shog9
    Commented Jan 10, 2019 at 20:31
  • Should be fixed completely now, @Glorfindel
    – Shog9
    Commented Jan 18, 2019 at 17:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .