1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 18:22:41 +01:00

Gracefully fail request if non existing callsign is passed to getrecentcommitsbypath instead of crashing

Summary:
`diffusion.getrecentcommitsbypath` fails with 500 error when non existing callsign is passed:
```
>>> UNRECOVERABLE FATAL ERROR <<<

Call to a member function getCommit() on null

```

Expected Behavior:
Return more graceful error notifying caller that such callsign/repository does not exist

Reproduction steps:
Open conduit: https://secure.phabricator.com/conduit/method/diffusion.getrecentcommitsbypath/
Enter:
callsign: "obviouslynotexisting"
path: "/random"
Click call method

Test Plan: after applying patch - call no longer fails with 500s

Reviewers: Pawka, epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D19558
This commit is contained in:
Arturas Moskvinas 2018-08-02 17:41:40 +03:00
parent 4c09e88c95
commit 356b2781bc

View file

@ -23,6 +23,12 @@ final class DiffusionGetRecentCommitsByPathConduitAPIMethod
);
}
protected function defineErrorTypes() {
return array(
'ERR_NOT_FOUND' => pht('Repository was not found.'),
);
}
protected function defineReturnType() {
return 'nonempty list<string>';
}
@ -36,6 +42,10 @@ final class DiffusionGetRecentCommitsByPathConduitAPIMethod
'branch' => $request->getValue('branch'),
));
if ($drequest === null) {
throw new ConduitException('ERR_NOT_FOUND');
}
$limit = nonempty(
$request->getValue('limit'),
self::DEFAULT_LIMIT);