Page MenuHomePhabricator

Errors in refs defined in a references tag are not reported correctly in the Parsoid implementation of Cite
Open, HighPublicBUG REPORT

Description

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

Add a reference group with a named reference in it that is not in the text, like so:

<references>
<ref name="r">ref</ref>
</references>

Render it with Parsoid.

What happens?:

The reference is displayed without error.

image.png (1,141×229 px, 20 KB)

What should have happened instead?:

A cite_error_group_refs_without_references should be emitted, like it is the case with the legacy-parser implementation.

image.png (1,079×143 px, 26 KB)

Note

As investigated and correctly reported by @EmptySora, this issue is actually an issue for any error that should be reported in a reference defined in a references block. T384598 has been closed as duplicate for this reason.

Implementation (for review)

Since errors are being added to nodes and read from there for the display, this case is problematic because an unused list defined ref does not have a node. Therefore there is no place to display the error with the current code structure.

Possible solutions:

  • Add a new separate place to store errors (see also the discussed in the comment of this tickets).
  • But since the unused refs look like a unique use case, I am suggesting a simple workaround for this use case. (If more use cases come up, the cleaner solution could still be added later.) See https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Cite/+/1267101.

Outcome

image.png (1,194×204 px, 35 KB)

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
MSantos raised the priority of this task from Low to High.Jan 8 2026, 3:28 PM

@EmptySora are you still interested in working on this?

We put this on our board WMDE-TechWish (product board) . We could pick this up in 1-2 weeks, if @EmptySora is unable to support until then.

Change #1267101 had a related patch set uploaded (by Svantje Lilienthal; author: Svantje Lilienthal):

[mediawiki/extensions/Cite@master] Added error for unused list defined refs

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

The valid use case where a main ref is only defined in the reference list, but a subref is used in the article needs to be excluded.

Subreference of purely list-defined parent reference
<ref name="book-b" details="Subreference of purely list-defined parent reference (body)" />

==References==
<references>
<ref name="book-b">Purely list-defined parent reference (body)</ref>
</references>

The current workaround does not yet:

image.png (1,100×129 px, 33 KB)

Change #1268920 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] Change ref errors inside <references> from fatal to warning

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

Change #1269873 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] Re-enable older parser tests that don't fail any more

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

Change #1269982 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] Add missing <references> tag to a parser test

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

Change #1269982 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Add missing <references> tag to a parser test

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

The workaround is now somewhat re-implementing Validator code.
There are some differences now between the parser because, in contrast to the legacy parser (that looks for the string "details" in the wikitext.) parsoid is actually looking for gendered subreferences.
Since this leads to more errors - for example when the references in unreachable - we might need to rephrase or create a separate error message.

image.png (963×419 px, 137 KB)

Lets discuss this with PM and UX.

Change #1269873 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Re-enable older parser tests that don't fail any more

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

Change #1271763 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] [POC] Show previously lost errors below reflist

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

Change #1271763 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Show previously lost errors below reference list

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

Change #1275923 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] More narrow interface for ErrorUtils::addEmbeddedErrors

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

Change #1267101 abandoned by Thiemo Kreuz (WMDE):

[mediawiki/extensions/Cite@master] Added error for unused list defined refs

Reason:

This is at least partially obsolete via Idd362c6. Might still be used as inspiration for further work, but shouldn't be merged as it is.

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

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

[mediawiki/extensions/Cite@master] Errors added below ref list dirty when not responsive

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

Change #1282441 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Errors added below ref list dirty when not responsive

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

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

[mediawiki/extensions/Cite@wmf/1.47.0-wmf.1] Errors added below ref list dirty when not responsive

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

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

[mediawiki/extensions/Cite@wmf/1.46.0-wmf.26] Errors added below ref list dirty when not responsive

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

Change #1282723 abandoned by Awight:

[mediawiki/extensions/Cite@wmf/1.47.0-wmf.1] Errors added below ref list dirty when not responsive

Reason:

cherry-picking to 1.46.0-wmf.26 instead

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

Change #1282723 restored by Awight:

[mediawiki/extensions/Cite@wmf/1.47.0-wmf.1] Errors added below ref list dirty when not responsive

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

Change #1282723 merged by jenkins-bot:

[mediawiki/extensions/Cite@wmf/1.47.0-wmf.1] Errors added below ref list dirty when not responsive

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

I've added this task as a blocker for MW-1.46, because we want https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Cite/+/1282723 to be backported to the release branch (and not only the train branch).

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

[mediawiki/extensions/Cite@REL1_46] Errors added below ref list dirty when not responsive

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

Change #1283023 merged by jenkins-bot:

[mediawiki/extensions/Cite@REL1_46] Errors added below ref list dirty when not responsive

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

Removing blocker status since this has been merged to 1.46 release.

Change #1282804 merged by jenkins-bot:

[mediawiki/extensions/Cite@wmf/1.46.0-wmf.26] Errors added below ref list dirty when not responsive

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

Mentioned in SAL (#wikimedia-operations) [2026-05-05T20:46:12Z] <arlolra@deploy1003> Started scap sync-world: Backport for [[gerrit:1282930|hCaptcha: Add diagnostic context to script load error logs (T424496)]], [[gerrit:1282397|sectionCollapsing: Scroll to fragment target on init (T425290)]], [[gerrit:1282804|Errors added below ref list dirty when not responsive (T384599)]]

Mentioned in SAL (#wikimedia-operations) [2026-05-05T20:48:09Z] <arlolra@deploy1003> mpostoronca, h2o, awight, arlolra: Backport for [[gerrit:1282930|hCaptcha: Add diagnostic context to script load error logs (T424496)]], [[gerrit:1282397|sectionCollapsing: Scroll to fragment target on init (T425290)]], [[gerrit:1282804|Errors added below ref list dirty when not responsive (T384599)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be ve

Mentioned in SAL (#wikimedia-operations) [2026-05-05T20:57:11Z] <arlolra@deploy1003> Finished scap sync-world: Backport for [[gerrit:1282930|hCaptcha: Add diagnostic context to script load error logs (T424496)]], [[gerrit:1282397|sectionCollapsing: Scroll to fragment target on init (T425290)]], [[gerrit:1282804|Errors added below ref list dirty when not responsive (T384599)]] (duration: 10m 59s)

Change #1275923 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] More narrow interface for ErrorUtils::addEmbeddedErrors

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

After the roll back the error for unused list-defined refs looks unfortunately like this:

image.png (719×188 px, 15 KB)

https://test.wikipedia.org/wiki/CiteTests#Reflist_with_list-defined_references

Wikitext:

== Reflist with list-defined references ==
<references group="group3">
<ref name="ldr1">In group</ref>
<ref name="ldr-unused">Unused</ref>
</references>

(We're assuming that "rollback" means "backport" here.)

The error appears the same in legacy and parsoid. It appears that Cite is constructing the cite error incorrectly. This might be a side effect of missing some piece from a rather complicated backport and might be fixed when the train rolls today. We don't think the backport of this specific patch was responsible for this specific issue.

@ABreault-WMF and @awight, can you take a look?

[…] egregious dirtying of that page

@ABreault-WMF, can you help us understand the issue better?

We understand what about="#mwt…" does and why it's needed when a DOM forest is not wrapped in a shared outer <div>. We understand the patch that adds the missing about attribute.

We can also see the effect in the roundtrip tests. They produce wikitext like <references>…</references><span class="error … with misplaced <span> elements that are left behind because of the missing about attributes.

What we don't understand is where this issue surfaces, outside of tests? I tried various things in VisualEditor but was never able to get a "dirty page".

Set $wgCiteResponsiveReferences = false; on your wiki

(This is the case on many production wikis https://gerrit.wikimedia.org/g/operations/mediawiki-config/+/3f505d76fe6cf2f2277947d70e44c3763cc19420/wmf-config/InitialiseSettings.php#7443)

Revert the above patch and create a page on the wiki with the test case,

<references>
<ref name="unused">whoops</ref>
<ref name="unused2">whoops2</ref>
</references>

Add a paragraph above in VE and review your changes,

Screenshot 2026-05-11 at 12.45.56 PM.png (1,832×830 px, 145 KB)

Ah, thanks a lot! That worked. With this I can even see the unexpected elements in VE.