mantisbt-plugins / source-integration

Source control integration plugin framework for MantisBT, including support for Github, Gitlab, Bitbucket, Gitea, Gitweb, Cgit, Subversion, Mercurial and more
http://noswap.com/projects/source-integration/
MIT License
181 stars 130 forks source link

Invalid Github API token causes webhook to fail silently #380

Open dregad opened 2 years ago

dregad commented 2 years ago

The Webhook delivery results in an HTTP 200 return code, but the response is actually a MantisBT error page: INTERNAL APPLICATION ERROR

Delivering the payload with $g_show_detailed_errors = ON; yields additional information

Client error: `GET https://api.github.com/rate_limit?per_page=100` resulted in a `401 Unauthorized` response:
{
"message": "Bad credentials",
"documentation_url": "https://docs.github.com/rest"
}

Stack trace

0   .../vendor/guzzlehttp/guzzle/src/Middleware.php 65  GuzzleHttp\Exception\RequestException   ::  create  -
1   .../vendor/guzzlehttp/promises/src/Promise.php  204 GuzzleHttp\Middleware   ::  GuzzleHttp\{closure}    -
2   .../vendor/guzzlehttp/promises/src/Promise.php  153 GuzzleHttp\Promise\Promise  ::  callHandler -
3   .../vendor/guzzlehttp/promises/src/TaskQueue.php    48  GuzzleHttp\Promise\Promise  ::  GuzzleHttp\Promise\{closure}    -
4   .../vendor/guzzlehttp/promises/src/Promise.php  248 GuzzleHttp\Promise\TaskQueue    ->  run -
5   .../vendor/guzzlehttp/promises/src/Promise.php  224 GuzzleHttp\Promise\Promise  ->  invokeWaitFn    -
6   .../vendor/guzzlehttp/promises/src/Promise.php  269 GuzzleHttp\Promise\Promise  ->  waitIfPending   -
7   .../vendor/guzzlehttp/promises/src/Promise.php  226 GuzzleHttp\Promise\Promise  ->  invokeWaitList  -
8   .../vendor/guzzlehttp/promises/src/Promise.php  62  GuzzleHttp\Promise\Promise  ->  waitIfPending   -
9   .../vendor/guzzlehttp/guzzle/src/Client.php 182 GuzzleHttp\Promise\Promise  ->  wait    -
10  .../vendor/guzzlehttp/guzzle/src/Client.php 95  GuzzleHttp\Client   ->  request -
11  .../plugins/SourceGithub/SourceGithub.php   506 GuzzleHttp\Client   ->  __call  -
12  .../plugins/SourceGithub/SourceGithub.php   546 SourceGithubPlugin  ->  api_get -
13  .../plugins/SourceGithub/SourceGithub.php   720 SourceGithubPlugin  ->  api_json_url    -
14  .../plugins/SourceGithub/SourceGithub.php   639 SourceGithubPlugin  ->  import_commits  -
15  .../plugins/Source/Source.API.php   524 SourceGithubPlugin  ->  commit  -
16  .../plugins/source-integration/Source/pages/checkin.php 86  SourceVCSWrapper    ->  __call  -
17  .../plugin.php  74  -   -   include <string>'/srv/plugins/source-integration/Source/pages/checkin.php'

The Guzzle RequestException should be caught and reported as a meaningful error.

dregad commented 2 years ago

Same root cause as #266

dregad commented 1 month ago

Problem will probably be fixed by https://mantisbt.org/bugs/view.php?id=34634