[go: up one dir, main page]

Page MenuHomePhabricator

Wikibase API returns confusing error message when property does not exist
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:
The error message is "Could not find an entity with the ID \"$1\"." (sic, with the $1)

This is doubly confusing: first, it is unclear it is the property that doesn't exist, and not the entity (item etc.) passed in the 'entity' parameter. Secondly, the $1 instead of the value in the message makes one suspect the ID in the request was not parsed properly.

What should have happened instead?:
An error message specifically saying "Property P5831 doesn't exist".

Event Timeline

Pretty sure this is a bug in StatementModificationHelper::getSnakInstance() (code introduced in T238409):

		try {
			$snak = $this->snakFactory->newSnak( $propertyId, $params['snaktype'], $valueData );
			return $snak;
		} catch ( PropertyDataTypeLookupException $ex ) {
			$this->errorReporter->dieException( $ex, 'no-such-entity' );
		} catch ( InvalidArgumentException | OutOfBoundsException $ex ) {
			$this->errorReporter->dieException( $ex, 'invalid-snak' );
		}

It needs to pass the entity ID for the no-such-entity message. Right now I’m not 100% sure if dieException() supports that, though, or whether it needs to die slightly differently.