Posting via Ghost API gone wrong

An Admin API error I hadn't seen before, and what caused it.

Posting via Ghost API gone wrong
{"errorType":"InternalServerError",
"errorMessage":"Internal server error, cannot save post.",
"code":"UNEXPECTED_ERROR",
"name":"InternalServerError",
"context":"An unexpected error occurred, please try again. Cannot set property post of #<ListItem> which has only a getter",
"type":"InternalServerError",
"details":null,
"property":null,
"help":null,
"id":"56bf0460-d5b5-11ee-aea7-47cd6d44e93e",
"ghostErrorCode":null,"stack":["InternalServerError: Internal server error, cannot save post.","    at /var/task/node_modules/@tryghost/admin-api/lib/admin-api.js:463:33","  

Seen this one before? I spent a really long time on why my previously-working API calls to the Ghost Admin API were no longer working. This is maybe not the best error message I've ever seen, and it took me a very very long time, in part because the thing that broke was nowhere near the thing I was editing... I thought.

So, drumroll please:

This error is the result of trying to create a post in the Admin API (using the Javascript SDK, but it probably doesn't matter), using {format: html}, while accidentally feeding in malformed HTML. I lost over an hour to this one. I tried to rule out the problem by replacing my HTML with something simple really early on, but I was using the same HTML in two separate API calls, and didn't realize I was just swapping out which one was crashing first. Finally I fed my HTML through an HTML validator, and bingo. Turns out that nesting an image in a <ul> tag is unacceptable, and that's what my code was doing.

Argh.

Anyway, here's the error message, in hopes that it'll save someone else an hour!

Hey, before you go... If your finances allow you to keep this tea-drinking ghost and the freelancer behind her supplied with our hot beverage of choice, we'd both appreciate it!