Page MenuHomePhabricator

action=wbeditentity: Missing datavalue key for snaks should raise a more specified message
Closed, ResolvedPublic

Description

When a json for action=wbeditentity contains a snak, but that snak has no datavalue key the following error is given:

{code=internal_api_error_InvalidArgumentException, info=Exception Caught: Wikibase\SnakObject::newFromType got an array with to few constructor arguments}

The validation of the json should give a better error here to see the cause of the exception, instead of looking at the source.

Details

Reference
bz57768

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:32 AM
bzimport set Reference to bz57768.
bzimport added a subscriber: Unknown Object (MLST).

Could you provide some params that when passed to the api reproduce this?

Be creative: {"claims":[{"type":"statement","mainsnak":{"snaktype":"value","property":"P1"},"rank":"normal"}]}
for an existing item.

Only remove the datavalue from the input. There are maybe more possible combination, all should result in a proper error message and not in an api internal error. Maybe along to ::newFromType a ::isValidInput/::canCreateTypeFromInput or so is needed to do this, which calls internal the same stack than the type would do.

When catching the internal error there is no way to know the missing json key, which would be a nice information for the client.

Lydia_Pintscher removed a subscriber: Unknown Object (MLST).
Lydia_Pintscher removed a subscriber: Unknown Object (MLST).

I get a similar error.

{
  "servedby": "mw1017",
  "error": {
      "code": "internal_api_error_InvalidArgumentException",
      "info": "Exception Caught: Wikibase\\Lib\\Serializers\\SnakSerializer::newSnakFromType got an array with to few constructor arguments",
      "*": ""
  }
}
Lucie set Security to None.

got an array with to few constructor arguments

Well, just looking at this and not the code we could simply also say what is expected in this exception?
Or the one that we have detected is missing?

Really this should then also be caught and returned as a UsageException..

samuwmde lowered the priority of this task from Medium to Lowest.Feb 15 2018, 4:40 PM
samuwmde added a project: patch-welcome.
samuwmde moved this task from incoming to ready to go on the Wikidata board.
matej_suchanek updated the task description. (Show Details)