Page MenuHomePhabricator

HTTP 412 Errors when editing Officewiki
Closed, ResolvedPublic

Description

Time of effort editing Sandbox in officewiki, ~2023-03-09T14:44

See:

image.png (785×707 px, 46 KB)

Requests are to /w/api.php, response is HTTP 200 with this payload (prettified)

{
  "errors": [
    {
      "code": "visualeditor-docserver-http",
      "html": "<p>Error contacting the Parsoid/RESTBase server (HTTP 412): (no message)\n</p><!--__DTHASLEDECONTENT__--><!--__DTEMPTYTALKPAGE__-->",
      "module": "visualeditoredit"
    }
  ],
  "docref": "See https://office.wikimedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/&gt; for notice of API deprecations and breaking changes.",
  "servedby": "mw2358"
}

Event Timeline

ssastry subscribed.

Officewiki does not use RESTBase.

Change 896028 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/core@master] Revert "TransformHandler: Load stashed page bundle based on ETag."

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

FWIW, when I tried to edit an existing page on officewiki, it worked fine. When I tried to edit the same page again, it failed with a 412.

Change 896028 merged by jenkins-bot:

[mediawiki/core@master] Revert "TransformHandler: Load stashed page bundle based on ETag."

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

Change 896030 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/core@wmf/1.40.0-wmf.26] Revert "TransformHandler: Load stashed page bundle based on ETag."

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

Change 896030 merged by jenkins-bot:

[mediawiki/core@wmf/1.40.0-wmf.26] Revert "TransformHandler: Load stashed page bundle based on ETag."

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

Mentioned in SAL (#wikimedia-operations) [2023-03-09T17:38:05Z] <zabe@deploy2002> Started scap: Backport for [[gerrit:896030|Revert "TransformHandler: Load stashed page bundle based on ETag." (T331629)]]

Mentioned in SAL (#wikimedia-operations) [2023-03-09T17:39:46Z] <zabe@deploy2002> zabe and ssastry: Backport for [[gerrit:896030|Revert "TransformHandler: Load stashed page bundle based on ETag." (T331629)]] synced to the testservers: mwdebug2002.codfw.wmnet, mwdebug1002.eqiad.wmnet, mwdebug1001.eqiad.wmnet, mwdebug2001.codfw.wmnet

Mentioned in SAL (#wikimedia-operations) [2023-03-09T17:50:02Z] <zabe@deploy2002> Finished scap: Backport for [[gerrit:896030|Revert "TransformHandler: Load stashed page bundle based on ETag." (T331629)]] (duration: 11m 57s)

Analysis:

  • on officewiki, VE is configured to use REST endpoints exposed by the Parsoid extension directly. It doesn't use the new "direct" mode yet (which would use internal PHP calls), nor does it use RESTbase (like most wikis at the moment).
  • In this mode, VE' getPageHTml() will hit the page/html endpoint exposed by the Parsoid extension. It will send the stash parameter, but the endpoint does not support this parameter. So content does not get stashed. It does however return an ETag that identifies the rendered HTML.
  • When saving content, VE will use that etag in transformHTML() to set the If-Match header, and send it to the transform/html/to/wikitext endpoint defiend by the Parsoid extension.
  • Per Ida81a314f015e205f2081c68a82d486145097c92, Parsoid's transform/ endpoint will try to load a rendering based on the etag content if an If-Match is present. This fails, since no content was stashed, and triggers a 412 response.

Open question:

  • when trying to load the content identified by the If-Match header, the HtmlOutputRendererHelper should fall back to checking the parser cache if no match is found in the stash. It's not clear why no matching output is found in the parser cache. The parser cache doesn't get written because TemporaryParsoidHandlerParserCacheWriteRatio is set. This is currently 50% and was set to 20% before, which explains why editing would sometimes work.

Possible fixes:

  • Make parsoid's page/html endpoint support the stash flag
  • Make parsoid's page/html endpoint return no etag (and hope RESTbase doesn't need it)
  • Make parsoid's transform/ endpoint ignore the etag
  • Switch officewiki to the new direct mode.

Config used to reproduce the issue locally:

wfLoadExtension( 'VisualEditor' );
$wgVisualEditorDefaultParsoidClient = 'vrs';
$wgTemporaryParsoidHandlerParserCacheWriteRatio = 0;

$wgVirtualRestConfig['modules']['parsoid'] = [
	'url' => "$wgServer/w/rest.php/",
	'prefix' => $wgDBname, // The wiki prefix to use; deprecated
	'domain' => $wgServer
];

Change 896380 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] TransformHandler: Load stashed page bundle based on ETag.

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

Change 896036 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/services/parsoid@master] Re-apply "Restore proper ETag handling""

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

Change 896380 merged by jenkins-bot:

[mediawiki/core@master] TransformHandler: Load stashed page bundle based on ETag.

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

Change 897964 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] ParsoidHandlerTest: check no etag is emitted perdefault

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

Change 897964 merged by jenkins-bot:

[mediawiki/core@master] ParsoidHandlerTest: check no etag is emitted perdefault

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

Change 896036 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Re-apply "Restore proper ETag handling""

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

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

[mediawiki/vendor@master] Bump parsoid to 0.18.0-a2

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

Change 901245 merged by jenkins-bot:

[mediawiki/vendor@master] Bump parsoid to 0.18.0-a2

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

Change 928624 had a related patch set uploaded (by C. Scott Ananian; author: Daniel Kinzler):

[mediawiki/services/parsoid@REL1_40] Re-apply "Restore proper ETag handling""

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

Change 928624 merged by jenkins-bot:

[mediawiki/services/parsoid@REL1_40] Re-apply "Restore proper ETag handling""

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