Page MenuHomePhabricator

MediaWiki\\Storage\\RevisionAccessException - "No such slot: main" in API action=compare
Closed, ResolvedPublic

Description

https://en.wikipedia.org/w/api.php?action=query&action=compare&fromtitle=Albert_Einstein&fromslots=main&fromsection-main=0&torev=856739136&toslots=main&tosection-main=0

Not sure what the expected result is, but it certainly isn't this.

"error": {
    "code": "internal_api_error_MediaWiki\\Storage\\RevisionAccessException",
    "info": "[W4lSZApAIDsAABVc774AAABA] Caught exception of type MediaWiki\\Storage\\RevisionAccessException"
},
"servedby": "mw1347"

Event Timeline

MER-C created this task.Aug 31 2018, 2:48 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 31 2018, 2:48 PM
Anomie claimed this task.Aug 31 2018, 2:58 PM
Anomie added a subscriber: Anomie.

Exception is

2018-08-31 14:56:44 [W4lXLApAAE4AADEg@44AAAAT] mw1283 enwiki 1.32.0-wmf.19 exception ERROR: [W4lXLApAAE4AADEg@44AAAAT] /w/api.php?action=query&action=compare&fromtitle=Albert_Einstein&fromslots=main&fromsection-main=0&torev=856739136&toslots=main&tosection-main=0   MediaWiki\Storage\RevisionAccessException from line 111 of /srv/mediawiki/php-1.32.0-wmf.19/includes/Storage/RevisionSlots.php: No such slot: main {"exception_id":"W4lXLApAAE4AADEg@44AAAAT","exception_url":"/w/api.php?action=query&action=compare&fromtitle=Albert_Einstein&fromslots=main&fromsection-main=0&torev=856739136&toslots=main&tosection-main=0","caught_by":"mwe_handler"}
[Exception MediaWiki\Storage\RevisionAccessException] (/srv/mediawiki/php-1.32.0-wmf.19/includes/Storage/RevisionSlots.php:111) No such slot: main
  #0 /srv/mediawiki/php-1.32.0-wmf.19/includes/Storage/RevisionRecord.php(191): MediaWiki\Storage\RevisionSlots->getSlot(string)
  #1 /srv/mediawiki/php-1.32.0-wmf.19/includes/Storage/RevisionRecord.php(174): MediaWiki\Storage\RevisionRecord->getSlot(string, integer, User)
  #2 /srv/mediawiki/php-1.32.0-wmf.19/includes/diff/DifferenceEngine.php(1613): MediaWiki\Storage\RevisionRecord->getContent(string, integer, User)
  #3 /srv/mediawiki/php-1.32.0-wmf.19/includes/api/ApiComparePages.php(125): DifferenceEngine->setRevisions(MediaWiki\Storage\MutableRevisionRecord, MediaWiki\Storage\MutableRevisionRecord)
  #4 /srv/mediawiki/php-1.32.0-wmf.19/includes/api/ApiMain.php(1587): ApiComparePages->execute()
  #5 /srv/mediawiki/php-1.32.0-wmf.19/includes/api/ApiMain.php(531): ApiMain->executeAction()
  #6 /srv/mediawiki/php-1.32.0-wmf.19/includes/api/ApiMain.php(502): ApiMain->executeActionWithErrorHandling()
  #7 /srv/mediawiki/php-1.32.0-wmf.19/api.php(87): ApiMain->execute()
  #8 /srv/mediawiki/w/api.php(3): include(string)
  #9 {main}

That's clearly not right.

Bawolff renamed this task from MediaWiki\\Storage\\RevisionAccessException in API action=compare to MediaWiki\\Storage\\RevisionAccessException - "No such slot: main" in API action=compare.Aug 31 2018, 3:02 PM

When you specify toslots=main without totext-main it's previewing the revision as if the main slot were deleted (this is documented behavior). And there's no point in specifying tosection-main without totext-main.

So the fix for that query is to note that you actually wanted to do https://en.wikipedia.org/w/api.php?action=query&action=compare&fromtitle=Albert_Einstein&torev=856739136

But the API and/or difference engine should handle the situation better.

Change 456652 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@master] ApiComparePages: Clean up handling of slot deletion

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

Anomie moved this task from Unsorted to Needs Review on the MediaWiki-API board.
Anomie moved this task from Inbox to In Progress on the Multi-Content-Revisions board.

Change 456652 merged by jenkins-bot:
[mediawiki/core@master] ApiComparePages: Clean up handling of slot deletion

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

Anomie closed this task as Resolved.EditedSep 5 2018, 4:24 PM

The fix should be deployed to Wikimedia wikis with 1.32.0-wmf.22 or later, see https://www.mediawiki.org/wiki/MediaWiki_1.32/Roadmap for a schedule.

Note that the query in the task description will still raise an error, but the error will be more useful:

{
    "error": {
        "code": "compare-maintextrequired",
        "info": "Parameter \"fromtext-main\" is required when \"fromslots\" contains \"main\" (cannot delete the main slot).",
        "*": "See https://en.wikipedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes."
    },
    "servedby": "mwXXXX"
}
Jdforrester-WMF added a subscriber: Jdforrester-WMF.

Worth back-porting or can we live with this in prod for a fortnight?

Anomie added a comment.Sep 5 2018, 4:37 PM

This doesn't seem to be being hit very often, it's probably ok to wait. But if someone wants to backport it, I have no objection.

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:08 PM