Page MenuHomePhabricator

Erroneous digits in QuantityValue
Closed, ResolvedPublic

Description

In Quick Statements, V2, the command

Q4115189 P1117 -1.23~0.35

(I added a link to https://www.wikidata.org/wiki/Property:P1117 here , since Phabricator's auto-link to https://phabricator.wikimedia.org/P1117 is misleading)

triggers an edit that leads to a Wikidata quantity value
of

-1.229999999999999982236431605997495353221893310546875±0.350000000000000088817841970012523233890533447265625

instead of the expected -1.23±0.35.

This looks similar to T119226, but since I can't see any scientific notation involvement, I am filing this separately for the moment.

Event Timeline

Daniel_Mietchen renamed this task from Superfluous digits in QuantityValue to Erroneous digits in QuantityValue.Jan 21 2017, 9:21 PM

Probably this is a bug of QuickStatements, whose bug is not tracking here, but at https://bitbucket.org/magnusmanske/wikidata-todo/issues?q=quick.

Actually, the code repo is here:
https://phabricator.wikimedia.org/diffusion/2010/repository/master/

I would assume that WMF Phabricator would be used to track bugs for WMF-hosted tools and WMF-hosted source code, but I don't know how...

I have logged the actual request sent out to Wikidata API:

{"action":"wbcreateclaim","entity":"Q4115189","snaktype":"value","property":"P1117","value":"{\"amount\":1.2,\"upperBound\":1.5,\"lowerBound\":0.9,\"unit\":\"1\"}","summary":"#quickstatements","baserevid":434308794,"bot":1,"token":"4032ec53b9aebbfcc925e909b48f8c975885d571+\\","format":"json"}

It resulted in this edit:
https://www.wikidata.org/w/index.php?title=Q4115189&type=revision&diff=435074880&oldid=434308794

I'll be happy to fix anything you can find wrong in the JSON I pass to the API. But it looks OK to me...

I can confirm the described behavior and uploaded a patch that aims to fix the underlying issue in the Wikibase code base, see https://github.com/DataValues/Number/pull/115.

However, there is a super-trivial thing you can do, @Magnus: Please submit quantity values as strings, not numbers.

Don't:

{"amount":1.2,"upperBound":1.5,"lowerBound":0.9,"unit":"1"}

Do:

{"amount":"1.2","upperBound":"1.5","lowerBound":"0.9","unit":"1"}

By coincidence, I submitted a patch for this on Saturday: {D911}.

BTW that seems to be the problem on QS v1 too. If the simple fix with strings above works, maybe can be ported to quick_statements.php too, so we won't get bad data from that one too.

hoo subscribed.

Just needs a data-values/number release now.

Change 425777 had a related patch set uploaded (by Hoo man; owner: Hoo man):
[mediawiki/extensions/Wikibase@master] Update data-values/number to 0.10.0

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

Change 425777 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Update data-values/number to 0.10.0

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

hoo removed a project: Patch-For-Review.