@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Raise warning when accidentally submitting Conduit parameters as a JSON-encoded body

Summary: See T12447 for discussion. It is reasonably intuitive to try and pass Conduit parameters via a JSON-encoded HTTP body, but if you do so, you'll get an unhelpful messsage about how method so-and-so does not accept a parameter named "your_entire_json_body". Instead, detect this mistake and advise developers to use form-encoded parameters.

Test Plan:
Got a better error when attempting to make Conduit calls from React code. Tested the following additional invocations of Conduit and got the expected results without an error:

* From the Conduit UI
* With cURL:
```
~ $ curl http://local.phacility.com:8080/api/conpherence.querythread \
> -d api.token=api-tvv2zb565zrtueab5ddprmpxvrwb \
> -d ids[0]=1
```
* With `arc call-conduit`:
```
~ $ echo '{
> "ids": [
> 1
> ]
> }' | arc call-conduit --conduit-uri http://local.phacility.com:8080/ --conduit-token api-tvv2zb565zrtueab5ddprmpxvrwb conpherence.querythread
```

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D19944

+9
+9
src/applications/conduit/controller/PhabricatorConduitAPIController.php
··· 605 605 AphrontRequest $request, 606 606 $method) { 607 607 608 + $content_type = $request->getHTTPHeader('Content-Type'); 609 + 610 + if ($content_type == 'application/json') { 611 + throw new Exception( 612 + pht('Use form-encoded data to submit parameters to Conduit endpoints. '. 613 + 'Sending a JSON-encoded body and setting \'Content-Type\': '. 614 + '\'application/json\' is not currently supported.')); 615 + } 616 + 608 617 // Look for parameters from the Conduit API Console, which are encoded 609 618 // as HTTP POST parameters in an array, e.g.: 610 619 //