Skip to content

Internal Server Error in /V1/order/{orderId}/ship API Endpoint #38282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2018 Adobe
* All Rights Reserved.
*/
declare(strict_types=1);

namespace Magento\Webapi\Controller\Rest;

use Magento\Framework\Webapi\Exception as WebapiException;
use Magento\Framework\Webapi\Rest\Response as RestResponse;
use Magento\Framework\Webapi\ServiceOutputProcessor;
use Magento\Framework\Webapi\Rest\Response\FieldsFilter;
Expand All @@ -19,7 +20,7 @@
*/
class SynchronousRequestProcessor implements RequestProcessorInterface
{
const PROCESSOR_PATH = "/^\\/V\\d+/";
private const PROCESSOR_PATH = "/^\\/V\\d+/";

/**
* @var RestResponse
Expand Down Expand Up @@ -78,7 +79,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function process(\Magento\Framework\Webapi\Rest\Request $request)
{
Expand All @@ -92,7 +93,13 @@ public function process(\Magento\Framework\Webapi\Rest\Request $request)
/**
* @var \Magento\Framework\Api\AbstractExtensibleObject $outputData
*/
$outputData = call_user_func_array([$service, $serviceMethodName], $inputParams);
try {
// phpcs:disable Magento2.Functions.DiscouragedFunction
$outputData = call_user_func_array([$service, $serviceMethodName], $inputParams);
// phpcs:enable Magento2.Functions.DiscouragedFunction
} catch (\TypeError $e) {
throw new WebapiException(__($e->getMessage()));
}
$outputData = $this->serviceOutputProcessor->process(
$outputData,
$serviceClassName,
Expand All @@ -109,7 +116,7 @@ public function process(\Magento\Framework\Webapi\Rest\Request $request)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function canProcess(\Magento\Framework\Webapi\Rest\Request $request)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2016 Adobe
* All Rights Reserved.
*/
declare(strict_types=1);

Expand Down Expand Up @@ -181,6 +181,26 @@ public function testShipOrder()
);
}

/**
* @magentoApiDataFixture Magento/Sales/_files/order_new.php
*/
public function testShipOrderWithTypeError()
{
/** @var Order $existingOrder */
$existingOrder = $this->getOrder('100000001');

$requestData = [
'orderId' => $existingOrder->getId(),
'items' => "[]",
];

try {
$this->_webApiCall($this->getServiceInfo($existingOrder), $requestData);
$this->fail('Expected exception was not raised');
} catch (\Exception $exception) {
}
}

/**
* Tests that not providing a tracking number produces the correct error. See MAGETWO-95429
* @codingStandardsIgnoreStart
Expand Down