View Issue Details

IDProjectCategoryView StatusLast Update
0027973mantisbtapi restpublic2021-03-07 18:28
Reporterdregad Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.11.0 
Target Version2.25.0Fixed in Version2.25.0 
Summary0027973: REST API update issue triggers errors if payload is empty
Description

PATCH request to /issues/:issue_id endpoint, results in PHP errors if the payload is empty.

The API should fail with an HTTP 400 (bad request) instead.

Steps To Reproduce

curl -i --request PATCH "http://localhost/mantis/api/rest/issues/20362" --header 'Authorization: {{token}}' --header 'Content-Type: application/json'

HTTP/1.1 500 Internal Server Error
Date: Fri, 12 Feb 2021 00:42:02 GMT
Server: Apache/2.4.41 (Ubuntu)
Set-Cookie: PHPSESSID=l7h35ml6pktjnv3s8u6lhtfs9k; path=/; HttpOnly
Cache-Control: private, max-age=10800
Last-Modified: Thu, 11 Feb 2021 12:13:35 GMT
Content-Length: 3909
Connection: close
Content-Type: text/html;charset=UTF-8

&lt;html>&lt;head>&lt;meta http-equiv='Content-Type' content='text/html; charset=utf-8'>&lt;title>Slim Application Error&lt;/title>&lt;style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:65px;}&lt;/style>&lt;/head>&lt;body>&lt;h1>Slim Application Error&lt;/h1><p>The application could not run because of the following error:</p>&lt;h2>Details&lt;/h2>&lt;div><strong>Type:</strong> TypeError&lt;/div>&lt;div><strong>Message:</strong> array_merge(): Argument 0000002 must be of type array, null given&lt;/div>&lt;div><strong>File:</strong> /home/dregad/dev/mantisbt/api/rest/restcore/issues_rest.php&lt;/div>&lt;div><strong>Line:</strong> 375&lt;/div>&lt;h2>Trace&lt;/h2><pre>#0 /home/dregad/dev/mantisbt/api/rest/restcore/issues_rest.php(375): array_merge()
0000001 [internal function]: rest_issue_update()
0000002 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(40): call_user_func()
0000003 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/Route.php(281): Slim\Handlers\Strategies\RequestResponse->__invoke()
0000004 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\Route->__invoke()
0000005 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/Route.php(268): Slim\Route->callMiddlewareStack()
#6 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/App.php(503): Slim\Route->run()
0000007 /home/dregad/dev/mantisbt/api/rest/restcore/ApiEnabledMiddleware.php(40): Slim\App->__invoke()
#8 [internal function]: ApiEnabledMiddleware->__invoke()
0000009 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array()
#10 [internal function]: Slim\DeferredCallable->__invoke()
#11 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func()
0000012 /home/dregad/dev/mantisbt/api/rest/restcore/AuthMiddleware.php(91): Slim\App->Slim\{closure}()
#13 [internal function]: AuthMiddleware->__invoke()
#14 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array()
#15 [internal function]: Slim\DeferredCallable->__invoke()
#16 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func()
#17 /home/dregad/dev/mantisbt/api/rest/restcore/VersionMiddleware.php(31): Slim\App->Slim\{closure}()
#18 [internal function]: VersionMiddleware->__invoke()
#19 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array()
#20 [internal function]: Slim\DeferredCallable->__invoke()
0000021 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func()
#22 /home/dregad/dev/mantisbt/api/rest/restcore/OfflineMiddleware.php(35): Slim\App->Slim\{closure}()
#23 [internal function]: OfflineMiddleware->__invoke()
#24 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array()
#25 [internal function]: Slim\DeferredCallable->__invoke()
0000026 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func()
#27 /home/dregad/dev/mantisbt/api/rest/restcore/CacheMiddleware.php(30): Slim\App->Slim\{closure}()
#28 [internal function]: CacheMiddleware->__invoke()
0000029 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array()
#30 [internal function]: Slim\DeferredCallable->__invoke()
#31 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func()
#32 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->Slim\{closure}()
#33 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/App.php(392): Slim\App->callMiddlewareStack()
#34 /home/dregad/dev/mantisbt/vendor/slim/slim/Slim/App.php(297): Slim\App->process()
#35 /home/dregad/dev/mantisbt/api/rest/index.php(107): Slim\App->run()
#36 {main}</pre>&lt;/body>&lt;/html>
TagsNo tags attached.

Relationships

related to 0027981 closeddregad mc_issue_update() throws system warning when Project not specified in IssueData 

Activities

Related Changesets

MantisBT: master 9807fa20

2021-02-11 19:36:21

dregad

Details Diff
REST API PATCH /issue/:id now fails with HTTP 400

Previously, PHP warnings would be triggered when the payload is empty.

Fixes 0027973
Affected Issues
0027973
mod - api/rest/restcore/issues_rest.php Diff File

MantisBT: master 9455ceb8

2021-02-16 15:25:27

dregad

Details Diff
Fix more PHP warnings caused by empty payload

Send HTTP 400 response when getParsedBody()'s return value is empty.

Issue 0027973
Affected Issues
0027973
mod - api/rest/restcore/issues_rest.php Diff File
mod - api/rest/restcore/projects_rest.php Diff File
mod - api/rest/restcore/users_rest.php Diff File