Page MenuHomePhabricator

transform/wikitext endpoint returns error if content too large.
Closed, ResolvedPublic

Description

The transform/wikitext/to/mobile-html/ endpoint (which we use for previewing edits) returns HTTP 413 (Content Too Large) if a large-enough amount of text is given to it. Let's document the exact size that the endpoint deems "too large" and decide what our behavior should be in that case, or whether to potentially expand the maximum size at the endpoint level.

Event Timeline

@Dbrant do you have metrics about how often this happens?

It seems that the 413 comes from MW when mobileapps converts wikitext to html, possibly Parsoid.

@Dbrant do you have metrics about how often this happens?

We don't have client-side metrics for this, unfortunately, but it can be reproduced easily by editing a sufficiently large article and attempting to "preview" it. (The app will allow the edit to proceed; it's just the preview becomes broken with this error.)

It would just be useful to know the actual maximum content size that the wikitext/to/mobile-html/ endpoint supports, and whether it could possibly be increased to match the maximum wikitext size in mediawiki.

@Dbrant, how critical is it and how early do you need this fixed?

I tried a few requests and i managed to get a 413 Payload too large by sending a request like:

POST https://en.wikipedia.org/api/rest_v1/transform/wikitext/to/mobile-html/Earth
Body

{
 wikitext: "
'{102871 bytes of chars}'
"
}

More specifically here is a very verbose curl command:
https://phabricator.wikimedia.org/P80977

This error present in other wikis too (hi,mr,te) if you try to edit full page via app.

This error present in other wikis too (hi,mr,te) if you try to edit full page via app.

@Dbrant, how critical is it and how early do you need this fixed?

I don't believe it's critical, since it doesn't really "block" our workflow of editing articles; it just prevents a preview from being shown.
It would be useful to know what is the actual maximum length that this API currently supports. This way, we can at least have the option of working around the issue by explicitly truncating the wikitext that we submit for previewing.

Change #1179235 had a related patch set uploaded (by Arlolra; author: Arlolra):

[operations/deployment-charts@master] mobileapps: Change max_body_size to 2mb from the 100kb default

https://gerrit.wikimedia.org/r/1179235

I tried a few requests and i managed to get a 413 Payload too large by sending a request like:
...
wikitext: "
'{102871 bytes of chars}'

Looks like this needs setting,
app.use(bodyParser.json({ limit: app.conf.max_body_size || '100kb' }));
https://github.com/wikimedia/mediawiki-services-mobileapps/blob/master/app.js#L167

ABreault-WMF edited projects, added: Essential-Work; removed: Parsoid.

Change #1179235 merged by jenkins-bot:

[operations/deployment-charts@master] mobileapps: Change max_body_size to 2mb from the 100kb default

https://gerrit.wikimedia.org/r/1179235

...
More specifically here is a very verbose curl command:
https://phabricator.wikimedia.org/P80977

Post-deploy, this no longer returns a 413

I don't believe it's critical, since it doesn't really "block" our workflow of editing articles; it just prevents a preview from being shown.
It would be useful to know what is the actual maximum length that this API currently supports. This way, we can at least have the option of working around the issue by explicitly truncating the wikitext that we submit for previewing.

In T398838#11094762, the max_body_size was changed from 100kb to 2mb

It's been a month, and the solution hasn't been rolled out to alpha builds yet. For non-coder editors, the preview is an essential feature. Therefore, I am changing the status to "in progress" because it hasn't been resolved on the client side yet.

It's been a month, and the solution hasn't been rolled out to alpha builds yet. For non-coder editors, the preview is an essential feature. Therefore, I am changing the status to "in progress" because it hasn't been resolved on the client side yet.

It has been rolled out. Which article(s) are still returning 413 when previewed?

Any article which is lengthy enough will return this, Use full page edit.

Screenshot_20250922_212542_Wikipedia.jpg (720×1,555 px, 78 KB)

Any article which is lengthy enough will return this, Use full page edit.

Screenshot_20250922_212542_Wikipedia.jpg (720×1,555 px, 78 KB)

Can you give a specific example? (And could you provide the version of the app you're using?)

Sorry for the oversight. I reset the app data for the alpha version, and it’s working now. The screenshot I shared was of the F-Droid version r/2.7.50543-r-2025-07-31, which still has the issue. I used the article on Tamannaah Bhatia for editing.

This comment was removed by anoopspeaks.

Sounds good - closing; And note that r/2.7.50543-r-2025-07-31 is a bit outdated -- not sure why F-Droid hasn't synced to our latest version yet.