Would like to reopen T10456: Conduit interprets all arguments from curl requests as strings

Observed Behavior:
While submitting Unit test results to Harbormaster via curl
curl http://phabricator.fluffyspider.com.au/api/harbormaster.sendmessage
I got the following error:
{"result":null,"error_code":"ERR-CONDUIT-CORE","error_info":"Parameter 'duration' has invalid type. Expected type 'optional float|int', got type 'string'."}

Expected Behavior:
duration parameter is used to feed the test execution time in seconds but it is meant to be a float, because tests are fast. Phabricator should cope with that

Phabricator Version:
phabricator d2baa88171fcc3f327b157277afb905430b5a918 (Apr 28 2017) arcanist 5d0f5afca8cdba3effa822b1d0f0ed3d90fec8b6 (Apr 26 2017)
phutil a900d7b63e954e221efe140f0f33d3d701524aae (Apr 24 2017)

Reproduction Steps:
Using curl in command line:

curl http://phabricator.example.com.au/api/harbormaster.sendmessage \
    -d api.token=api-token \
    -d buildTargetPHID=PHID-HMBT-5lzk3e7xhj54toavod5v \
    -d type=pass \
    -d unit[0][name]=test1 \
    -d unit[0][result]=pass \
    -d unit[0][duration]=1.401 \
    -d unit[1][name]=test2 \
    -d unit[1][result]=fail
{"result":null,"error_code":"ERR-CONDUIT-CORE","error_info":"Parameter 'duration' has invalid type. Expected type 'optional float|int', got type 'string'."}

The same data goes through using internal Phabricator Conduit test page and the following JSON data

[{
	"duration": 1.401,
	"name": "test1",
	"result": "pass"
}, {
	"name": "test2",
	"result": "fail"
}]

Additional info:
We are using Phabricato for a while for continuous integration and love it
Phabricator / Harbormaster has been coupled with an external build/test system called buildbot (in Python)
I found this issue T10456 and it has been marked as resolved
I have a relatively up to date Phabricator version including this change. But it appears that it is not enough.
Last piece of info: we don’t actually use curl but some internal buildbot HTTP Post command and there are some other complications aroun it
I will be investigating on my spare time to fix this

Just to clarify, anything outside of a week is not considered up to date, since we do weekly promotions.

This may be https://secure.phabricator.com/T11887 if I understand the issue, or at least, would be resolved by the same fix.

Thanks for pointing out these commits. It will be very useful to investigate

I just confirmed I can reproduce the issue with today’s version:
phabricator e47f85cd98b869fe97b3e6143f5de0670039d6da (Wed, Jul 26)
arcanist 836768bdccd42ae6a0a95dca7760e25992067ffc (Sat, Jul 22)
phutil 0a4487d37cd72b3b91ac332377f2b12d4e5a2543 (Jun 23 2017)

{“result”:null,“error_code”:“ERR-CONDUIT-CORE”,“error_info”:“Parameter ‘duration’ has invalid type. Expected type ‘optional float|int’, got type ‘string’.”}

Can you suggest gd (Giedrius Dubinskas) to watch this post?

Finally I end up with this one liner change
The UnitMessage type is a dict within an array so it seems it cannot be checked earlier
I have to convert any incoming ‘duration’ before calling checkMap

diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php b/src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php
index 956850bd9..75716a355 100644
--- a/src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php
@@ -81,6 +81,7 @@ final class HarbormasterBuildUnitMessage
     // We're just going to ignore extra keys for now, to make it easier to
     // add stuff here later on.
     $dict = array_select_keys($dict, array_keys($spec));
+    $dict['duration'] = floatval(idx($dict, 'duration'));
     PhutilTypeSpec::checkMap($dict, $spec);
 
     $obj->setEngine(idx($dict, 'engine', ''));

Hi, just in case someone is going to fix this … same thing is happening for Lint messages for properties “line” and “char”.

Expected type ‘optional int’, got type ‘string’.