Page MenuHomePhabricator

Implement basic legacy parser error handling for the `details` attribute
Closed, ResolvedPublic

Description

When we aligned on the error message for the different details error case we need to implement these into the legacy and Parsoid parser code.

We might want to wait with that until the cleanup of that validation is done though. See T387002: Try to reduce duplicate code in reference validation

Error messages and case:

The document https://docs.google.com/document/d/1nqcttbeBaN2QiAIlpu1Cup7IJBuaQPCANyIF_g2wDms lists all possible error cases. The parent ticket T386212 discusses a few. So far we agreed on:

  • No main content due to missing or wrong name or empty content
    • Proposed error message:
      • "<ref> tag with details must have content or point to a parent by name." or
      • "<ref> tag with a details attribute must have main content or point to a main reference by name."
      • When a name is given but the parent not found the existing message "Invalid <ref> tag; no text was provided for refs named …" is correct, in our opinion.
    • Open question for WMDE-Design: Do you think we need a new message for the old scenario above? Or should the new message be shown instead?
    • Patch-For-Review: https://gerrit.wikimedia.org/r/1122130
  • There is no scenario in wich it makes sense to use details in the <references> block.
    • Proposed error message:
      • "<ref> tag with name "…" cannot use details when inside <references>." or
      • "<ref> tag with name "…" cannot use the details attribute when inside <references>." or
      • "References with details cannot be used inside of a <references> tag."
    • Open question for WMDE-Design: Including the name can be beneficial to track down the source of the error, but might not be needed for such a general message.
    • Patch-For-Review: https://gerrit.wikimedia.org/r/1121617
  • Combining follow and details doesn't make sense.
    • Proposed error message: "A <ref follow="…"> tag that is the continuation of a previous one cannot be named individually or have details." This intentionally combines two scenarios that are invalid for the same reason to not have to many almost identical error messages.
    • Open question for WMDE-Design: Should it mention the value in follow="…" to make it easier to find the source of the error? We don't think this is needed because it is almost guaranteed that there is only ever a single follow on a page.
    • Patch-For-Review: https://gerrit.wikimedia.org/r/1121620

Event Timeline

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

[mediawiki/extensions/Cite@master] [WIP] New error when using details inside <references>

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

The patch https://gerrit.wikimedia.org/r/1121617 solves 4 of the TODOs we collected so far in the parser tests file. 5 TODOs are left.

  • The most critical addition we need, in my opinion, is a new message for a valid looking <ref name"missingbook" details="page 1" /> that points to a parent that got lost. We could reuse the existing "Invalid <ref> tag; no text was provided for refs named …". That is technically correct, but we can probably do much better.
  • We already have cite_error_ref_follow_conflicts for invalid combinations of follow with other attributes. This message should be reused.
  • I think 2 or 3 of the TODOs don't need an error but are fine as they are.

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

[mediawiki/extensions/Cite@master] Add error when combining details with follows

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

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

[mediawiki/extensions/Cite@master] New error message for details without a parent

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

Change #1121617 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] New error message when using details inside <references>

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

Change #1122130 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] New error message for details without a parent

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

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

[mediawiki/extensions/Cite@master] Re-classify one "details" validator error as a warning

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

Change #1122550 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Re-classify one "details" validator error as a warning

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

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

[mediawiki/extensions/Cite@master] Use array to pass arguments to Validator

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

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

[mediawiki/extensions/Cite@master] Move existing argument sanitization into the Validator

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

@thiemowmde The error messages are a good selection. ✨ I made some reviews and collected some questions:

How about we add the errors to our example page in docker dev as well?

I am wondering why this error is only showing up in the preview and the read mode has a different one:

Screenshot from 2025-02-27 16-12-13.png (419×1 px, 70 KB)
Screenshot from 2025-02-27 16-12-31.png (254×890 px, 30 KB)

I am wondering why […] the read mode has a different one

That's the Parsoid output. We will update this later.

How about we add the errors to our example page in docker dev as well?

Docker dev already has an example page, that can be extended with the new error cases we found here.

I also added the page to beta wiki for better visibility: https://en.wikipedia.beta.wmflabs.org/wiki/CiteDetailsErrors

thiemowmde renamed this task from Implement error handling for the `details` attribute to Implement basic error handling for the `details` attribute.Feb 28 2025, 3:48 PM

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

[mediawiki/extensions/Cite@master] Fix duplicate errors on sub-ref and main reference

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

Change #1121620 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Add error when combining details with follows

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

awight renamed this task from Implement basic error handling for the `details` attribute to Implement basic legacy parser error handling for the `details` attribute.Mar 5 2025, 8:25 AM

Change #1123680 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Fix duplicate errors on sub-ref and main reference

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

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

[mediawiki/extensions/Cite@master] Higher priority for "no details in <references>" error message

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

Change #1126611 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Higher priority for "no details in <references>" error message

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

awight moved this task from Demo to Done on the WMDE-TechWish-Sprint-2025-03-19 board.