Page MenuHomePhabricator

LogicException when parsing section with list-defined references
Closed, DuplicatePublicPRODUCTION ERROR

Description

Create this page:

Blah blah.<ref name="foo"/>
==References==
{{reflist|refs=<ref name="foo">blah</ref>}}

Open the classic source editor on the "References" section, and attempt to preview the page.
Result is:

Request from xxx.xxx.xxx.xxx via cp1085 frontend, Varnish XID 45833706
Error: 503, Backend fetch failed at Sun, 12 Jan 2020 22:53:39 GMT

Alternately, try: https://en.wikipedia.org/w/api.php?action=parse&sectionpreview&title=foo&text={{reflist|refs%3D%3Cref%20name%3D%22bar%22%3Ebaz%3C%2Fref%3E}}
Result is:

{
    "error": {
        "code": "internal_api_error_LogicException",
        "info": "[XhujygpAMD8AAJykxxoAAACK] Caught exception of type LogicException",
        "errorclass": "LogicException"
    },
    "servedby": "mw1228"
}

This may be related to T240248.
(Originally reported by Dominic Mayers at enwiki Village pump)

Details

Request URL
https://en.wikipedia.org/w/api.php?action=parse&sectionpreview&title=foo&text=

Event Timeline

suffusion_of_yellow renamed this task from LogicException when previewing section with list-defined references to LogicException when parsing section with list-defined references.Jan 12 2020, 11:32 PM
Ammarpad changed the subtype of this task from "Task" to "Production Error".
Ammarpad set Request URL to https://en.wikipedia.org/w/api.php?action=parse&sectionpreview&title=foo&text=.Jan 13 2020, 3:47 AM

Note the test cases given don't actually depend on a Template:Reflist or the use of {{#tag:references}}, they also work with <references>. But it does depend on section preview: in a non-section parse, validateRefInReferences() generates a "cite_error_references_missing_group" or "cite_error_references_missing_key" error which avoids this code path.

2020-01-13 12:51:09 [XhxnvQpAMEUAAHeo0gsAAACS] mw1234 enwiki 1.35.0-wmf.14 exception ERROR: [XhxnvQpAMEUAAHeo0gsAAACS] /w/api.php?action=parse&sectionpreview&title=foo&text=%3Creferences%3E%3Cref%20name%3D%22bar%22%3Ebaz%3C%2Fref%3E%3C/references%3E   LogicException from line 421 of /srv/mediawiki/php-1.35.0-wmf.14/extensions/Cite/src/ReferenceStack.php: Unknown ref "bar" in group "" {"exception_id":"XhxnvQpAMEUAAHeo0gsAAACS","exception_url":"/w/api.php?action=parse&sectionpreview&title=foo&text=%3Creferences%3E%3Cref%20name%3D%22bar%22%3Ebaz%3C%2Fref%3E%3C/references%3E","caught_by":"mwe_handler"} 
[Exception LogicException] (/srv/mediawiki/php-1.35.0-wmf.14/extensions/Cite/src/ReferenceStack.php:421) Unknown ref "bar" in group ""
  #0 /srv/mediawiki/php-1.35.0-wmf.14/extensions/Cite/src/Cite.php(333): Cite\ReferenceStack->appendText(string, string, string)
  #1 /srv/mediawiki/php-1.35.0-wmf.14/extensions/Cite/src/Cite.php(134): Cite\Cite->guardedRef(Parser, string, array)
  #2 /srv/mediawiki/php-1.35.0-wmf.14/extensions/Cite/src/Hooks/CiteParserTagHooks.php(36): Cite\Cite->ref(string, array, Parser)
  #3 /srv/mediawiki/php-1.35.0-wmf.14/includes/parser/Parser.php(4046): Cite\Hooks\CiteParserTagHooks::ref(string, array, Parser, PPFrame_Hash)
  #4 /srv/mediawiki/php-1.35.0-wmf.14/includes/parser/PPFrame_Hash.php(327): Parser->extensionSubstitution(array, PPFrame_Hash)
  #5 /srv/mediawiki/php-1.35.0-wmf.14/includes/parser/Parser.php(3115): PPFrame_Hash->expand(PPNode_Hash_Tree, integer)
  #6 /srv/mediawiki/php-1.35.0-wmf.14/includes/parser/Parser.php(1478): Parser->replaceVariables(string)
  #7 /srv/mediawiki/php-1.35.0-wmf.14/includes/parser/Parser.php(793): Parser->internalParse(string, boolean, boolean)
  #8 /srv/mediawiki/php-1.35.0-wmf.14/extensions/Cite/src/Cite.php(458): Parser->recursiveTagParse(string)
  #9 /srv/mediawiki/php-1.35.0-wmf.14/extensions/Cite/src/Cite.php(413): Cite\Cite->guardedReferences(string, array, Parser)
  #10 /srv/mediawiki/php-1.35.0-wmf.14/extensions/Cite/src/Hooks/CiteParserTagHooks.php(63): Cite\Cite->references(string, array, Parser)
  #11 /srv/mediawiki/php-1.35.0-wmf.14/includes/parser/Parser.php(4046): Cite\Hooks\CiteParserTagHooks::references(string, array, Parser, PPFrame_Hash)
  #12 /srv/mediawiki/php-1.35.0-wmf.14/includes/parser/PPFrame_Hash.php(327): Parser->extensionSubstitution(array, PPFrame_Hash)
  #13 /srv/mediawiki/php-1.35.0-wmf.14/includes/parser/Parser.php(3115): PPFrame_Hash->expand(PPNode_Hash_Tree, integer)
  #14 /srv/mediawiki/php-1.35.0-wmf.14/includes/parser/Parser.php(1478): Parser->replaceVariables(string)
  #15 /srv/mediawiki/php-1.35.0-wmf.14/includes/parser/Parser.php(586): Parser->internalParse(string)
  #16 /srv/mediawiki/php-1.35.0-wmf.14/includes/content/WikitextContent.php(368): Parser->parse(string, Title, ParserOptions, boolean, boolean, NULL)
  #17 /srv/mediawiki/php-1.35.0-wmf.14/includes/content/AbstractContent.php(555): WikitextContent->fillParserOutput(Title, NULL, ParserOptions, boolean, ParserOutput)
  #18 /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiParse.php(270): AbstractContent->getParserOutput(Title, NULL, ParserOptions)
  #19 /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiMain.php(1603): ApiParse->execute()
  #20 /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiMain.php(539): ApiMain->executeAction()
  #21 /srv/mediawiki/php-1.35.0-wmf.14/includes/api/ApiMain.php(510): ApiMain->executeActionWithErrorHandling()
  #22 /srv/mediawiki/php-1.35.0-wmf.14/api.php(78): ApiMain->execute()
  #23 /srv/mediawiki/w/api.php(3): require(string)
  #24 {main}