Skip to content

Commit a7149bc

Browse files
committed
AC-746: Malformed request body or parameters cause "Internal Server Error"
Removed plugin as it is causing multiple WebAPI test failures
1 parent ad9bb39 commit a7149bc

File tree

3 files changed

+8
-90
lines changed

3 files changed

+8
-90
lines changed

app/code/Magento/Webapi/Model/Plugin/Framework/Api/FilterPlugin.php

Lines changed: 0 additions & 78 deletions
This file was deleted.

app/code/Magento/Webapi/etc/webapi_rest/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,4 @@
8383
<type name="Magento\Store\Model\Validation\StoreCodeValidator">
8484
<plugin name="check_if_parsed_store_code_is_valid" type="Magento\Webapi\Model\Plugin\Store\Model\Validation\StoreCodeValidator"/>
8585
</type>
86-
<type name="Magento\Framework\Api\Filter">
87-
<plugin name="validate_search_criteria_field" type="Magento\Webapi\Model\Plugin\Framework\Api\FilterPlugin" sortOrder="10"/>
88-
</type>
8986
</config>

lib/internal/Magento/Framework/Webapi/ErrorProcessor.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,8 @@ public function maskException(\Exception $exception)
145145
$stackTrace
146146
);
147147
} else {
148-
// Check if this is a client error based on message content
149-
$httpCode = ($this->isClientError($exception))
150-
? WebapiException::HTTP_BAD_REQUEST
151-
: WebapiException::HTTP_INTERNAL_ERROR;
148+
// Check if this is a client error based on the exception type
149+
$httpCode = $this->getClientErrorHttpCode($exception);
152150
$message = $exception->getMessage();
153151
$code = $exception->getCode();
154152
//if not in Dev mode, make sure the message and code is masked for unanticipated exceptions
@@ -172,13 +170,14 @@ public function maskException(\Exception $exception)
172170
}
173171

174172
/**
175-
* Determine if an exception is a client error based on the exception type
173+
* Return the HTTP code for a client error based on the exception type
176174
*
177175
* @param \Exception $exception
178-
* @return bool
176+
* @return int
179177
*/
180-
private function isClientError(\Exception $exception)
178+
private function getClientErrorHttpCode(\Exception $exception)
181179
{
180+
// Check if this is a client error based on the exception type
182181
if ($exception instanceof \Zend_Db_Exception
183182
|| $exception instanceof \Zend_Db_Adapter_Exception
184183
|| $exception instanceof \Zend_Db_Statement_Exception
@@ -188,9 +187,9 @@ private function isClientError(\Exception $exception)
188187
|| $exception instanceof \UnexpectedValueException
189188
|| $exception instanceof \Magento\Framework\Search\Request\NonExistingRequestNameException
190189
) {
191-
return true;
190+
return WebapiException::HTTP_BAD_REQUEST;
192191
}
193-
return false;
192+
return WebapiException::HTTP_INTERNAL_ERROR;
194193
}
195194

196195
/**

0 commit comments

Comments
 (0)