@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.

Throw ERR-CONDUIT-CALL for non-existing methods with >64 characters

Summary:
Phorge shows a cryptic `AphrontQueryException #1406: Data too long for column 'method'` error when trying to access a non-existing Conduit API method with more than 64 characters, like `http://phorge.localhost/api/whateverwhateverwhateverwhateverwhateverwhateverwhateverwhateverwhateverwhatever`.
The failure in logging the call (`PhabricatorConduitMethodCallLog` defines `'method' => 'text64'`) is thrown before reaching the code to show the expected error `Conduit API method does not exist.`

Thus truncate the method name to 64 characters (the method call will fail anyway at this stage, no matter which invalid method name was used) to still be able to log the attempt && fail with a useful error message.

Closes T16146

Test Plan:
* Go to http://phorge.localhost/api/whateverwhateverwhateverwhateverwhateverwhateverwhateverwhateverwhateverwhatever
* Get a proper `ERR-CONDUIT-CALL` instead of a confusing `(AphrontQueryException) #1406: Data too long for column 'method' at row 1`
* Look at http://phorge.localhost/conduit/log/query/all/, the failed call is still logged

Reviewers: O1 Blessed Committers, mainframe98

Reviewed By: O1 Blessed Committers, mainframe98

Subscribers: mainframe98, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16146

Differential Revision: https://we.phorge.it/D26130

+9
+9
src/applications/conduit/controller/PhabricatorConduitAPIController.php
··· 9 9 10 10 public function handleRequest(AphrontRequest $request) { 11 11 $method = $request->getURIData('method'); 12 + // PhabricatorConduitMethodCallLog limits 'method' to 'text64' so truncate 13 + // the method name. This entire call will fail anyway; truncation allows us 14 + // to at least show a meaningful error message instead of returning a raw 15 + // DB write error while still logging the failed call in the Call Logs. 16 + $limit = 64; 17 + if (strlen($method) > $limit) { 18 + $method = substr($method, 0, $limit); 19 + } 20 + 12 21 $time_start = microtime(true); 13 22 14 23 $api_request = null;