Testing another issue, by uploading an invalid XML file I got an error of Import failed: Expected <mediawiki> tag, got script.
It wasn't obvious that the error message was all there due to a lack of any trailing punctuation or similar.
See also: T259527: Special:Import failed at Wikispecies: "Import failed: Expected <mediawiki> tag, got", which highlights the error too (though, is presumably about the import actually failing, and the lack of anything identified).
if ( $this->reader->localName != 'mediawiki' ) { // phpcs:ignore Generic.PHP.NoSilencedErrors @libxml_disable_entity_loader( $oldDisable ); $error = libxml_get_last_error(); if ( $error ) { throw new NormalizedException( "XML error at line {line}: {message}", [ 'line' => $error->line, 'message' => $error->message, ] ); } else { throw new MWException( "Expected <mediawiki> tag, got " . $this->reader->localName ); } }
https://www.php.net/manual/en/class.xmlreader.php#xmlreader.props.localname
Something like Import failed: Expected '<mediawiki>' tag, got '<{$this->reader->localName}>' tag. would be better than what is there now. tag/node/element work too.
Then in practice, we'd get Import failed: Expected '<mediawiki>' tag, got '<script>' tag.
Looks like XML error at line {line}: {message} could be similarly confusing from a lack of termination.