"specified index out of bounds" issue when moving a statement
Closed, ResolvedPublic

Description

There are certain scenarios when moving a statement in the UI results in an "specified index is out of bounds" error.

https://www.wikidata.org/wiki/Wikidata:Contact_the_development_team#Exception_Caught:_Specified_index_is_out_of_bounds


Version: master
Severity: major
Whiteboard: backlog

Details

Reference
bz58394
bzimport set Reference to bz58394.
bzimport added a subscriber: Unknown Object (MLST).

This occurs, for example, when adding three statements with a property not yet featured by the item.
The UI sends the correct information, although the baseRevId sent along with the request is, of course, the one received when the item was loaded since that one is not updated by the "add statement" operation.
When the entity content is loaded in the SetClaim module, the initial set of claims/statements as to the baseRevId is loaded and passed to ChangeOpClaim. Consequently, the statements just added are missing and the index where to place the statements within the flat list of statements is wrong because the statements previously added are not detected being in the list of statements.

I've seen this happen plenty (10+) times. How to reproduce:

  • Add a new claim (new property) to a page
  • Add a second claim with the same property
  • Try to add a third claim to the same property -> POOF
Magnus added a comment.Jan 9 2014, 7:15 PM

For completeness' sake, it can happen for the second claim already.

Exception Caught: Specified index is out of bounds"

#0 extensions\Wikibase\vendor\wikibase\data-model\src\Wikibase\DataModel\ByPropertyIdArray.php(432): Wikibase\DataModel\ByPropertyIdArray->moveObjectToIndex(Object(Wikibase\DataModel\Claim\Statement), 3)
#1 extensions\Wikibase\repo\includes\ChangeOp\ChangeOpClaim.php(100): Wikibase\DataModel\ByPropertyIdArray->addObjectAtIndex(Object(Wikibase\DataModel\Claim\Statement), 3)
#2 extensions\Wikibase\repo\includes\api\SetClaim.php(64): Wikibase\ChangeOp\ChangeOpClaim->apply(Object(Wikibase\DataModel\Entity\Item))
#3 includes\api\ApiMain.php(861): Wikibase\Api\SetClaim->execute()
#4 includes\api\ApiMain.php(362): ApiMain->executeAction()
#5 includes\api\ApiMain.php(333): ApiMain->executeActionWithErrorHandling()
#6 api.php(76): ApiMain->execute()
#7 {main}~

Occours whenever the index submitted to wbsetclaim is 2 above the number of claims currently in the item for the baserevid that has been submitted.

i.e. 1 claim on item for baserevid 888 >> submit a new claim with index 3 >> Exception

Change 108503 had a related patch set uploaded by Addshore:
Clean up error for claim index out of bounds

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

Change 108527 had a related patch set uploaded by Addshore:
Implement hack to avoid UI throwing this error

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

Change 108503 merged by Jeroen De Dauw:
Clean up error for claim index out of bounds

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

Change 108672 had a related patch set uploaded by Addshore:
Clean up error for claim index out of bounds

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

Change 108672 merged by jenkins-bot:
Clean up error for claim index out of bounds

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

Change 108527 merged by jenkins-bot:
Implement hack to avoid UI throwing this error

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

Add Comment