Page MenuHomePhabricator

Improve handling of diffs between different content types
Open, Needs TriagePublicPRODUCTION ERROR

Description

An attempt to diff two different content types (where at least one is non-text-based) typically results in an exception being thrown. This is bad form as it results in production errors (any two revisions can be diffed, and it's often possible to change the content type of a page into something incompatible). It's even worse with MCR where only one slot having different content types results in an error page, even though the user might have a legitimate need to see the diff of another slot.

Either the exception should be more specific (right now it tends to be just plain Exception, MWException, AssertionError or something similarly vague) and callers should handle it, or instead of throwing we should just return an error string (as Wikibase handled it in gerrit 349878, although it seems that re-broke since).

Event Timeline

Change 485575 had a related patch set uploaded (by Gergő Tisza; owner: Gergő Tisza):
[mediawiki/core@master] [WIP] Improve handling of diffs between incompatible content models

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

Change 485746 had a related patch set uploaded (by Gergő Tisza; owner: Gergő Tisza):
[mediawiki/extensions/MassMessage@master] Improve handling of diffs between incompatible content models

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

Change 485575 had a related patch set uploaded (by Tim Starling; author: Gergő Tisza):

[mediawiki/core@master] Improve handling of diffs between incompatible content models

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

Change 485575 merged by jenkins-bot:

[mediawiki/core@master] Improve handling of diffs between incompatible content models

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

Removing myself since I don't see how I can help. Please add me back if my help is needed.

I have removed a log filter from Kibana MediaWiki New Errors dashboard which pointed to the duplicate task T231084. There is no hit over the last four weeks.

The filter was:

{
  "query": {
    "regexp": {
      "labels.normalized_message": {
        "value": "Bad value for parameter .oldContent: must be a.+"
      }
    }
  }
}

There was an another filter mentioning T214217 which I have removed as well:

{
  "query": {
    "match_phrase": {
      "error.message": "Cannot diff content types other than MassMessageListContent"
    }
  }
}
Error
normalized_message
[{reqId}] {exception_url}   InvalidArgumentException: Can only diff two entities of the same type
FrameLocationCall
from/srv/mediawiki/php-1.44.0-wmf.19/extensions/Wikibase/lib/packages/wikibase/data-model-services/src/Diff/EntityDiffer.php(47)
#0/srv/mediawiki/php-1.44.0-wmf.19/extensions/Wikibase/lib/packages/wikibase/data-model-services/src/Diff/EntityDiffer.php(40)Wikibase\DataModel\Services\Diff\EntityDiffer->assertTypesMatch(Wikibase\DataModel\Entity\Property, Wikibase\DataModel\Entity\Item)
#1/srv/mediawiki/php-1.44.0-wmf.19/extensions/Wikibase/repo/includes/Content/EntityContent.php(374)Wikibase\DataModel\Services\Diff\EntityDiffer->diffEntities(Wikibase\DataModel\Entity\Property, Wikibase\DataModel\Entity\Item)
#2/srv/mediawiki/php-1.44.0-wmf.19/extensions/Wikibase/repo/includes/Diff/EntitySlotDiffRenderer.php(34)Wikibase\Repo\Content\EntityContent->getDiff(Wikibase\Repo\Content\ItemContent)
#3/srv/mediawiki/php-1.44.0-wmf.19/includes/diff/DifferenceEngine.php(1438)Wikibase\Repo\Diff\EntitySlotDiffRenderer->getDiff(Wikibase\Repo\Content\PropertyContent, Wikibase\Repo\Content\ItemContent)
#4/srv/mediawiki/php-1.44.0-wmf.19/includes/diff/DifferenceEngine.php(1338)DifferenceEngine->getDiffBody()
#5/srv/mediawiki/php-1.44.0-wmf.19/includes/diff/DifferenceEngine.php(1298)DifferenceEngine->getDiff(string, string, string)
#6/srv/mediawiki/php-1.44.0-wmf.19/includes/diff/DifferenceEngine.php(1038)DifferenceEngine->showDiff(string, string, string)
#7/srv/mediawiki/php-1.44.0-wmf.19/includes/page/Article.php(1067)DifferenceEngine->showDiffPage(bool)
#8/srv/mediawiki/php-1.44.0-wmf.19/includes/page/Article.php(482)Article->showDiffPage()
#9/srv/mediawiki/php-1.44.0-wmf.19/extensions/Wikibase/repo/includes/Actions/ViewEntityAction.php(80)Article->view()
#10/srv/mediawiki/php-1.44.0-wmf.19/extensions/Wikibase/repo/includes/Actions/ViewEntityAction.php(55)Wikibase\Repo\Actions\ViewEntityAction->showEntityPage()
#11/srv/mediawiki/php-1.44.0-wmf.19/includes/actions/ActionEntryPoint.php(732)Wikibase\Repo\Actions\ViewEntityAction->show()
#12/srv/mediawiki/php-1.44.0-wmf.19/includes/actions/ActionEntryPoint.php(509)MediaWiki\Actions\ActionEntryPoint->performAction(Article, MediaWiki\Title\Title)
#13/srv/mediawiki/php-1.44.0-wmf.19/includes/actions/ActionEntryPoint.php(145)MediaWiki\Actions\ActionEntryPoint->performRequest()
#14/srv/mediawiki/php-1.44.0-wmf.19/includes/MediaWikiEntryPoint.php(202)MediaWiki\Actions\ActionEntryPoint->execute()
#15/srv/mediawiki/php-1.44.0-wmf.19/index.php(58)MediaWiki\MediaWikiEntryPoint->run()
#16/srv/mediawiki/w/index.php(3)require(string)
#17{main}
Impact
Notes

Can only diff two entities of the same type

This is a hard-coded limitation in the MediaWiki-extensions-Wikibase-Repo code. I think it's better to track this in a separate ticket.

I remember bringing this up many, many years ago. I can think of two ways forward.

  • To actually lift the limitation we would need to implement a new, generic entity differ that does it's best to show the differences between any two (possibly even unknown) entity types. It could, for example, check if both entity types have known elements like labels or statements (almost all have) and produce nice output for such element. Unknown elements could be diffed directly based on the JSON. The problem with this approach is that it's a lot of work for very little benefit. While we are aware of one or two situations on wikidata.org where it would be a nice-to-have feature, it would probably only be used once a month or week. PM never considered this worth the developer's time.
  • We could leave the logic untouched but convert the exception into a proper user-facing message.
Restricted Application changed the subtype of this task from "Task" to "Production Error". · View Herald TranscriptJun 29 2026, 2:54 PM