Page MenuHomePhabricator

Charts not being output correctly in Parsoid
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:
The wiki-chart does not have a data-mw attribute so renders as an SVG and is not progressively enhanced with the echarts library

What should have happened instead?:
The data-mw attribute should be present.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

CCiufo-WMF moved this task from Backlog to Up Next on the Charts board.
MSantos edited projects, added Parsoid (Tracking); removed Parsoid.

Why is the echarts library looking at the data-mw attribute?

For security reasons. We do not want to enhance charts with the echarts library with untrusted data.

The {{#chart}} in question is embedded inside an {{image frame}} template, and Parsoid generally doesn't have data-mw attributes inside transcluded content.

We do sanitize attributes starting with data-mw- so adding a data-mw-charts=true attribute to the element should be sufficient to robustly mark it as safe to enhance.

We do sanitize attributes starting with data-mw- so adding a data-mw-charts=true attribute to the element should be sufficient to robustly mark it as safe to enhance.

Is there a typo here? If I understand correctly you are saying the data-mw attribute itself will be stripped by Parsoid but anything prefixed data-mw will not. Is that correct?

Change #1152785 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/Chart@master] Fixes: Charts embedded in template rendering in Parsoid

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

Change #1152785 merged by jenkins-bot:

[mediawiki/extensions/Chart@master] Fixes: Charts embedded in template rendering in Parsoid

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

Change #1153281 had a related patch set uploaded (by Bvibber; author: Jdlrobson):

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.4] Fixes: Charts embedded in template rendering in Parsoid

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

Change #1153282 had a related patch set uploaded (by Bvibber; author: Jdlrobson):

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.3] Fixes: Charts embedded in template rendering in Parsoid

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

Change #1153282 merged by jenkins-bot:

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.3] Fixes: Charts embedded in template rendering in Parsoid

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

Change #1153281 merged by jenkins-bot:

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.4] Fixes: Charts embedded in template rendering in Parsoid

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

Mentioned in SAL (#wikimedia-operations) [2025-06-03T16:32:56Z] <bvibber@deploy1003> Started scap sync-world: Backport for [[gerrit:rGERRIT11532826b37b|Fixes: Charts embedded in template rendering in Parsoid (T395462)]], [[gerrit:1153281|Fixes: Charts embedded in template rendering in Parsoid (T395462)]]

Mentioned in SAL (#wikimedia-operations) [2025-06-03T16:35:00Z] <bvibber@deploy1003> bvibber: Backport for [[gerrit:rGERRIT11532826b37b|Fixes: Charts embedded in template rendering in Parsoid (T395462)]], [[gerrit:1153281|Fixes: Charts embedded in template rendering in Parsoid (T395462)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-06-03T16:42:50Z] <bvibber@deploy1003> Finished scap sync-world: Backport for [[gerrit:rGERRIT11532826b37b|Fixes: Charts embedded in template rendering in Parsoid (T395462)]], [[gerrit:1153281|Fixes: Charts embedded in template rendering in Parsoid (T395462)]] (duration: 09m 54s)

We do sanitize attributes starting with data-mw- so adding a data-mw-charts=true attribute to the element should be sufficient to robustly mark it as safe to enhance.

Is there a typo here? If I understand correctly you are saying the data-mw attribute itself will be stripped by Parsoid but anything prefixed data-mw will not. Is that correct?

Yes. I'd phrase it slightly differently, as "the data-mw attribute is generated by Parsoid for editing-related information and it is not guaranteed to be present on transcluded content, since parsoid moves the editing information to the outermost transclusion wrapper. However, all attributes prefixed by data-mw are reserved for system use and will be removed from user-generated content, in both the legacy parser and parsoid, so using a different attribute prefixed by data-mw, like data-mw-chart, is a great way to mark your content as "safe to enhance" in a way which doesn't depend on Parsoid's editing annotations."

We previously went through this for progressive enhancement of OOUI content, and so data-ooui is another "safe" prefix which is sanitized from user content, but that's proabably less appropriate for this use.

Change #1153306 had a related patch set uploaded (by Bvibber; author: Bvibber):

[operations/deployment-charts@master] Update chart-renderer to 2025-06-03-165036-production

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

Change #1153306 merged by jenkins-bot:

[operations/deployment-charts@master] Update chart-renderer to 2025-06-03-165036-production

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

The chart-renderer-side patch appears not to match the client-side patch, which I didn't catch until deploying it., leading to all client-side rendering failing on new page renders. chart-renderer was outputting data-mw-chart="true" and data-chart="...json data..." but the client-side code was looking for JSON data inside data-mw-chart.

I've reverted the chart-renderer patch and restored the previous version to production for now.

Change #1153658 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/Chart@master] Update Charts so they can render from data-mw-charts as well as data-charts

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

Change #1153662 had a related patch set uploaded (by Bvibber; author: Jdlrobson):

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.3] Update Charts so they can render from data-mw-charts as well as data-charts

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

Change #1153663 had a related patch set uploaded (by Bvibber; author: Jdlrobson):

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.4] Update Charts so they can render from data-mw-charts as well as data-charts

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

Change #1153658 merged by jenkins-bot:

[mediawiki/extensions/Chart@master] Update Charts so they can render from data-mw-charts as well as data-charts

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

Change #1153662 merged by jenkins-bot:

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.3] Update Charts so they can render from data-mw-charts as well as data-charts

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

Change #1153663 merged by jenkins-bot:

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.4] Update Charts so they can render from data-mw-charts as well as data-charts

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

Mentioned in SAL (#wikimedia-operations) [2025-06-04T17:53:18Z] <bvibber@deploy1003> Started scap sync-world: Backport for [[gerrit:1153662|Update Charts so they can render from data-mw-charts as well as data-charts (T395462)]], [[gerrit:1153663|Update Charts so they can render from data-mw-charts as well as data-charts (T395462)]]

Mentioned in SAL (#wikimedia-operations) [2025-06-04T17:55:30Z] <bvibber@deploy1003> bvibber: Backport for [[gerrit:1153662|Update Charts so they can render from data-mw-charts as well as data-charts (T395462)]], [[gerrit:1153663|Update Charts so they can render from data-mw-charts as well as data-charts (T395462)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-06-04T18:03:24Z] <bvibber@deploy1003> Finished scap sync-world: Backport for [[gerrit:1153662|Update Charts so they can render from data-mw-charts as well as data-charts (T395462)]], [[gerrit:1153663|Update Charts so they can render from data-mw-charts as well as data-charts (T395462)]] (duration: 10m 05s)

Change #1153680 had a related patch set uploaded (by Bvibber; author: Bvibber):

[operations/deployment-charts@master] Update chart-renderer service for Parsoid template fix

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

Change #1153680 merged by jenkins-bot:

[operations/deployment-charts@master] Update chart-renderer service for Parsoid template fix

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

Change #1154087 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/extensions/Chart@master] Fix back compat for data-chart

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

The chart-renderer-side patch appears not to match the client-side patch, which I didn't catch until deploying it., leading to all client-side rendering failing on new page renders. chart-renderer was outputting data-mw-chart="true" and data-chart="...json data..." but the client-side code was looking for JSON data inside data-mw-chart.

I've reverted the chart-renderer patch and restored the previous version to production for now.

This issue resurfaced after yesterday's deployment, but only for cached pages. That should be addressed by https://gerrit.wikimedia.org/r/1154087

Change #1154087 merged by jenkins-bot:

[mediawiki/extensions/Chart@master] Fix back compat for data-chart

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

Change #1154098 had a related patch set uploaded (by Jdlrobson; author: Catrope):

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.4] Fix back compat for data-chart

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

Change #1154098 merged by jenkins-bot:

[mediawiki/extensions/Chart@wmf/1.45.0-wmf.4] Fix back compat for data-chart

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

Mentioned in SAL (#wikimedia-operations) [2025-06-05T20:14:06Z] <jdlrobson@deploy1003> Started scap sync-world: Backport for [[gerrit:1154098|Fix back compat for data-chart (T395462)]]

Mentioned in SAL (#wikimedia-operations) [2025-06-05T20:16:05Z] <jdlrobson@deploy1003> jdlrobson: Backport for [[gerrit:1154098|Fix back compat for data-chart (T395462)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-06-05T20:24:12Z] <jdlrobson@deploy1003> Finished scap sync-world: Backport for [[gerrit:1154098|Fix back compat for data-chart (T395462)]] (duration: 10m 05s)

The fix that @Catrope wrote is now also backported.