Page MenuHomePhabricator

TypeError: content.parts is undefined
Open, Needs TriagePublicPRODUCTION ERROR

Description

https://logstash.wikimedia.org/app/dashboards#/doc/logstash-*/logstash-2021.04.02?id=b2q-k3gBWKe2MTdRfquA

at ve.dm.MWTransclusionNode.static.getWikitext URL1:172:298
at ve.dm.MWTransclusionNode.prototype.getWikitext URL1:173:852
at ve.ce.MWTransclusionNode.prototype.generateContents URL1:177:642
at ve.ce.GeneratedContentNode.prototype.forceUpdate URL2:564:553
at ve.ce.GeneratedContentNode.prototype.update URL2:564:312
at ve.ce.CXTransclusionBlockNode.prototype.update URL3:518:609
at VeCeGeneratedContentNode URL2:561:26
at VeCeMWTransclusionNode URL1:175:475
at VeCeCXTransclusionNode URL3:517:560
at VeCeCXTransclusionBlockNode URL3:517:810
at OO.Factory.prototype.create URL4:231:422
at ve.ce.NodeFactory.prototype.createFromModel URL2:392:60
at ve.ce.BranchNode.prototype.onSplice URL2:406:618
at OO.EventEmitter.prototype.emit URL4:223:479
at ve.dm.BranchNode.prototype.splice URL2:91:862
at splice URL2:158:862
at ve.dm.TreeModifier.static.applyTreeOperation URL2:162:902
at ve.dm.TreeModifier.static.applyTreeOperations URL2:158:86
at ve.dm.TreeModifier.prototype.process URL2:164:184
at ve.dm.TransactionProcessor.prototype.process URL2:109:859
at ve.dm.Document.prototype.commit URL2:233:227
at ve.dm.Surface.prototype.changeInternal URL2:193:704
at ve.dm.Surface.prototype.change URL2:193:219
at ve.init.mw.CXTarget.prototype.setSectionContent URL4:1272:269
at ve.init.mw.CXTarget.prototype.changeContentSource/< URL4:1274:830
at mightThrow URL4:110:141
at resolve/</process< URL4:110:800

URL1: https://gl.wikipedia.org/w/load.php?lang=gl&modules=ext.visualEditor.desktopTarget%2Cicons%2Clanguage%2Cmwalienextension%2Cmwextensions%2Cmwformatting%2Cmwgallery%2Cmwimage%2Cmwlanguage%2Cmwtransclusion%7Cext.visualEditor.mwextensions.desktop%7Cext.visualEditor.mwimage.core&skin=vector&version=sw2mt
URL2: https://gl.wikipedia.org/w/load.php?lang=gl&modules=ext.visualEditor.base%2Ccore%2Cdiffing%2Cmediawiki%2Cmwcore%2Cmwlink%2Cmwmeta%2CprogressBarWidget%2Csanitize%2CsupportCheck%2Cswitching%2CtargetLoader%2CtempWikitextEditorWidget%2Ctrack%2Cve%2Cwelcome%7Cext.visualEditor.core.desktop%2Cutils%7Cext.visualEditor.core.utils.parsing%7Cext.visualEditor.desktopArticleTarget.init&skin=vector&version=14t4d
URL3: https://gl.wikipedia.org/w/load.php?lang=gl&modules=ext.CodeMirror.visualEditor%7Cext.CodeMirror.visualEditor.init%7Cext.abuseFilter.visualEditor%7Cext.cite.styles%2CvisualEditor%7Cext.cite.visualEditor.core%2Cdata%7Cext.citoid.visualEditor%7Cext.citoid.visualEditor.data%7Cext.confirmEdit.CaptchaInputWidget%2CvisualEditor%7Cext.disambiguator.visualEditor%7Cext.geshi.visualEditor%7Cext.graph.data%2CvisualEditor%7Cext.kartographer%7Cext.kartographer.editing%2Cutil%2CvisualEditor%7Cext.math.styles%2CvisualEditor%7Cext.score.visualEditor%7Cext.score.visualEditor.icons%7Cext.spamBlacklist.visualEditor%7Cext.templateDataGenerator.editPage%7Cext.titleblacklist.visualEditor%7Cext.visualEditor.data%2CmoduleIcons%2CmoduleIndicators%7Cext.wikihiero.visualEditor%7Cext.wikimediaEvents.visualEditor%7Cmediawiki.ForeignStructuredUpload%2CForeignUpload%2CUpload%7Cmediawiki.ForeignStructuredUpload.BookletLayout%7Cmediawiki.Upload.BookletLayout%7Cmediawiki.language.names%7Cmediawiki.libs.jpegmeta%7Cmediawiki.page.gallery.styles%7Cmediawiki.widgets.CategoryMultiselectWidget%2CDateInputWidget%2CMediaSearch%2CStashedFileWidget%2CTable%2CUserInputWidget%7Cmediawiki.widgets.DateInputWidget.styles%7Cmoment%7Cmw.cx.visualEditor%7Cmw.cx.visualEditor.base%2Ccontent%2Clink%2Cmt%2CpublishSettings%2Csection%2Csentence%7Coojs-ui.styles.icons-editing-citation%2Cicons-editing-list%2Cicons-editing-styling%2Cicons-layout%2Cicons-location%2Cicons-media%2Cicons-moderation%2Cicons-movement&skin=vector&version=98jtj
URL4: https://gl.wikipedia.org/w/load.php?lang=gl&modules=diffMatchPatch%2Cdompurify%2Cjquery%2Coojs%2Coojs-ui%2Coojs-ui-core%2Coojs-ui-toolbars%2Coojs-ui-widgets%2Coojs-ui-windows%2Cpapaparse%2Crangefix%2Csite%2Cspark-md5%2CtreeDiffer%2Cunicodejs%7Cext.centralNotice.geoIP%7Cext.centralauth.ForeignApi%7Cext.centralauth.centralautologin.clearcookie%7Cext.cx.eventlogging.campaigns%7Cext.cx.model%2Cutil%7Cext.cx.widgets.spinner%7Cext.cx.wikibase.link%7Cext.echo.api%2Cinit%7Cext.eventLogging%2CnavigationTiming%2CwikimediaEvents%7Cext.uls.common%2Ccompactlinks%2Cinterface%2Cpreferences%2Cwebfonts%7Cjquery.client%2Ccookie%2Ctablesorter%2CtextSelection%7Cjquery.tablesorter.styles%7Cjquery.uls.data%7Cmediawiki.ForeignApi%2CString%2CTitle%2CUri%2Capi%2Cbase%2Ccldr%2Ccookie%2Cdeflate%2Cexperiments%2CjqueryMsg%2Clanguage%2Cmisc-authed-pref%2Cpulsatingdot%2Cstorage%2Cuser%2Cutil%2Cwidgets%7Cmediawiki.ForeignApi.core%7Cmediawiki.action.view.redirectPage%7Cmediawiki.editfont.styles%7Cmediawiki.interface.helpers.styles%7Cmediawiki.language.months%7Cmediawiki.libs.pluralruleparser%7Cmediawiki.page.ready%7Cmediawiki.skinning.content.parsoid%7Cmediawiki.ui.button%7Cmediawiki.widgets.styles%7Cmw.cx.MachineTranslation%2CMwApiRequestManager%2CSiteMapper%2Cdm%2Cinit%2Cui%2Cutil%7Cmw.cx.dm.PageTitleModel%2CTranslation%2CTranslationIssue%2CWikiPage%7Cmw.cx.init.Translation%7Cmw.cx.tools.IssueTrackingTool%2CTranslationTool%2CTranslationToolFactory%7Cmw.cx.ui.Categories%2CCategoryMultiselectWidget%2CHeader%2CInfobar%2CMessageWidget%2CPageTitleWidget%2CPersonalMenuWidget%2CTranslationToolWidget%2CTranslationView%7Coojs-ui-core.icons%2Cstyles%7Coojs-ui-toolbars.icons%7Coojs-ui-widgets.icons%7Coojs-ui-windows.icons%7Coojs-ui.styles.icons-accessibility%2Cicons-content%2Cicons-editing-advanced%2Cicons-editing-core%2Cicons-interactions%2Cicons-user%2Cicons-wikimedia%2Cindicators%7Cskins.vector.legacy.js%7Cuser.defaults%7Cve.ce.CXLintableNode%7Cve.dm.CXLintableNode%7Cve.init.mw.CXTarget%7Cve.ui.CXDesktopContext%2CCXSurface&skin=vector&version=dsox3

Another stack trace with same error message: https://logstash.wikimedia.org/app/dashboards#/doc/logstash-*/logstash-2021.04.02?id=uvW5k3gBGiM4niWIJCZg

at ve.dm.MWTransclusionNode.prototype.getPartsList URL1:173:466
at ve.ce.MWTransclusionNode.static.getTemplatePartDescriptions URL1:175:971
at ve.ce.MWTransclusionNode.static.getDescription URL1:176:377
at ve.ce.FocusableNode.prototype.getInvisibleIconLabel URL2:427:136
at ve.ce.FocusableNode.prototype.updateInvisibleIconLabel URL2:427:272
at ve.ce.FocusableNode.prototype.createInvisibleIcon URL2:427:2
at ve.ce.FocusableNode.prototype.updateInvisibleIconSync URL2:426:524
at ve.ce.FocusableNode.prototype.updateInvisibleIcon/< URL2:426:365

URL1: https://vi.wikipedia.org/w/load.php?lang=vi&modules=ext.visualEditor.desktopTarget%2Cicons%2Clanguage%2Cmwalienextension%2Cmwextensions%2Cmwformatting%2Cmwgallery%2Cmwimage%2Cmwlanguage%2Cmwtransclusion%7Cext.visualEditor.mwextensions.desktop%7Cext.visualEditor.mwimage.core&skin=vector&version=1t5i1
URL2: https://vi.wikipedia.org/w/load.php?lang=vi&modules=ext.visualEditor.base%2Ccore%2Cdiffing%2Cmediawiki%2Cmwcore%2Cmwlink%2Cmwmeta%2CprogressBarWidget%2Csanitize%2CsupportCheck%2Cswitching%2CtargetLoader%2CtempWikitextEditorWidget%2Ctrack%2Cve%2Cwelcome%7Cext.visualEditor.core.desktop%2Cutils%7Cext.visualEditor.core.utils.parsing%7Cext.visualEditor.desktopArticleTarget.init&skin=vector&version=2vuti

Event Timeline

Krinkle subscribed.

This one is seen a fair bit. 500 entries in the last month.

  • Wikis: 193x es.wikipedia.org, 44x fr.wikipedia.org, ...
  • Browsers: Firefox 92, 91, 90, and 89. Affecting Firefox on Windows, macOS, Linux, and Android.
  • URLs: Special:ContentTranslation. I spot checked ten different entries and they were all for Special:ContentTranslation.

Logstash query for reference: https://logstash.wikimedia.org/goto/9c2ffbfd65bf4e9c9f54321dc6bf066a

image.png (526×2 px, 80 KB)

Looks like about 100/month to me, but maybe I'm searching wrong.

The issue is not browser-specific, but different browsers generate different error messages, so people looking through the logs and reporting bugs get confused (including myself).

Possible error messages include:

  • content.parts is undefined (Firefox)
  • undefined is not an object (evaluating 'content.parts.length') (Safari)
  • Cannot read properties of undefined (reading 'length') (Chrome) [unhelpfully, this doesn't include the "content.parts" in any way, so searching for this error produces many unrelated results]

When you combine them, and filter by stack trace because the Chrome message is unhelpful, you get a Logstash query like this: https://logstash.wikimedia.org/goto/b50946fc0147f60b53b90895b1616866 message:"content.parts is undefined" OR message:"undefined is not an object (evaluating 'content.parts.length')" OR ( message:"Cannot read properties of undefined (reading 'length')" AND ( stack_trace:ve.dm.MWTransclusionNode.static.getWikitext OR stack_trace:ve.dm.MWTransclusionNode.getPartsList ) )

image.png (525×2 px, 69 KB)

Error rate definitely increased on December 2. This was a Friday, so this could be a change in that week's train, but it could also be something else.


The description of T324750 has reproduction steps (I can reproduce). It involves copy-pasting templates between pages, although we don't know what about those templates causes the problem.

The December 2 bump is caused by change 858588 Upgrade DOMPurify to 2.4.1. We use this library on the pasted content to protect users against XSS attacks in HTML they might paste from external websites. Unfortunately, it looks like the new version will reject any HTML attributes that contain />, including VE's information about templates when any parameter contains />.

This happens here in the code: https://gerrit.wikimedia.org/g/VisualEditor/VisualEditor/+/225741274840708288bdef404ce93460a2b9e9b0/lib/dompurify/purify.js#1273.

As far as I can tell, this was a workaround for the security issue described in https://blog.jquery.com/2020/04/10/jquery-3-5-0-released/ (not affecting us, since we're using a newer version). The previous version had an option to enable it, which we were not using. Then it was removed: https://github.com/cure53/DOMPurify/commit/661571886064ee7465bcf7d295cfe5038beab9a4#diff-ac7cd96b8f4b994868af43ac8aff25573dd7cede1aab33fdcfd438811c7e853d and added back the same day but now unconditional, without the option: https://github.com/cure53/DOMPurify/commit/5daf669bb90c2de107a023607924482ef66d3c6f#diff-ac7cd96b8f4b994868af43ac8aff25573dd7cede1aab33fdcfd438811c7e853d. I have no idea what the goal of this was, it's not described in the commits.

This doesn't explain the errors before December 2. I don't think we ever found a way to reproduce those.

I've commented upstream as it doesn't look there is an easy local workaround. We could convert self-closing tags to open tags but this may have unwanted side-effects.

A more generic fix here might be to only sanitize HTML when it is used in the view, something we did in T322704, however if we could keep sanitizing all external HTML that arrives in the DM that would make things more fool-proof.

Change 889196 had a related patch set uploaded (by Esanders; author: Esanders):

[VisualEditor/VisualEditor@master] Update DOMPurify to 2.4.4

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

Change 889196 merged by jenkins-bot:

[VisualEditor/VisualEditor@master] Update DOMPurify to 2.4.4

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

Change 889249 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (3b05386e0)

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

Change 889249 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (3b05386e0)

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

ppelberg subscribed.

We should check the logs again after deployment.

This seems to be ready for doing the above, assuming the patch rode the train that rolled out on 21-Feb.

Re-checking the query from T279215#8525064: https://logstash.wikimedia.org/goto/b50946fc0147f60b53b90895b1616866

image.png (516×2 px, 58 KB)

It seems that we're back to the previous rate of errors from 2021.

I still see this, and perhaps the cause is different than in the above? My steps to reproduce are:

The stack trace suggests there's some kind of race condition, in which nodes have not gotten their wikitext content ahead of rendering? User experience is that templated content is incrementally rendered one block at a time, so there seems to be plenty of opportunity for out-of-order rendering or initialization.

Uncaught TypeError: content.parts is undefined
    getWikitext ve.dm.MWTransclusionNode.js:392
    getWikitext ve.dm.MWTransclusionNode.js:494
    generateContents ve.ce.MWTransclusionNode.js:183
    forceUpdate ve.ce.GeneratedContentNode.js:315
    update ve.ce.GeneratedContentNode.js:295
ve.dm.MWTransclusionNode.js:392:24
    getWikitext ve.dm.MWTransclusionNode.js:392
    getWikitext ve.dm.MWTransclusionNode.js:494
    generateContents ve.ce.MWTransclusionNode.js:183
    forceUpdate ve.ce.GeneratedContentNode.js:315
    update ve.ce.GeneratedContentNode.js:295
    VeCeGeneratedContentNode ve.ce.GeneratedContentNode.js:25
    VeCeMWTransclusionNode ve.ce.MWTransclusionNode.js:26
    VeCeMWTransclusionInlineNode ve.ce.MWTransclusionInlineNode.js:18
    create oojs.js:1683
    createFromModel ve.ce.NodeFactory.js:68
    viewNodes ve.ce.BranchNode.js:214
    map self-hosted:178
    onSplice ve.ce.BranchNode.js:206
    onSplice ve.ce.ContentBranchNode.js:147
    emit oojs.js:858
    splice ve.dm.BranchNode.js:125
    splice ve.dm.TreeModifier.js:157
    applyTreeOperation ve.dm.TreeModifier.js:341
    applyTreeOperations ve.dm.TreeModifier.js:105
    process ve.dm.TreeModifier.js:394
    process ve.dm.TransactionProcessor.js:110
    commit ve.dm.Document.js:417
    changeInternal ve.dm.Surface.js:971
    change ve.dm.Surface.js:940
    change ve.dm.SurfaceFragment.js:125
    insertDocument ve.dm.SurfaceFragment.js:943
    afterPasteInsertExternalData ve.ce.ClipboardHandler.js:983
    afterPasteAddToFragmentFromExternal ve.ce.ClipboardHandler.js:934
    afterPaste ve.ce.ClipboardHandler.js:523
    onPaste ve.ce.ClipboardHandler.js:287
    (Async: setTimeout handler)
    onPaste ve.ce.ClipboardHandler.js:283
    jQuery 9
    VeCeClipboardHandler ve.ce.ClipboardHandler.js:33
    createClipboardHandler ve.ce.Surface.js:320
    VeCeSurface ve.ce.Surface.js:91
    createView ve.ui.Surface.js:336
    VeUiSurface ve.ui.Surface.js:84
    VeUiMWSurface ve.ui.MWSurface.js:18
    createSurface ve.init.mw.Target.js:330
    createSurface ve.init.mw.ArticleTarget.js:1768
    addSurface ve.init.Target.js:577
    addSurface ve.init.mw.Target.js:383
    addSurface ve.init.mw.DesktopArticleTarget.js:196
    setupSurface ve.init.mw.Target.js:367
    (Async: setTimeout handler)
    setupSurface ve.init.mw.Target.js:366
    (Async: setTimeout handler)
    setupSurface ve.init.mw.Target.js:355
    documentReady ve.init.mw.Target.js:263
    documentReady ve.init.mw.ArticleTarget.js:451
    loadSuccess ve.init.mw.ArticleTarget.js:342
    loadSuccess ve.init.mw.DesktopArticleTarget.js:310
    jQuery 5
Restricted Application changed the subtype of this task from "Task" to "Production Error". · View Herald TranscriptApr 17 2025, 3:14 AM