Search code examples
shopwareshopware6shopware6-api

Shopware6 order state transition throws 500 status code error


we have a technical issue with the API that performs the order state transition on our Shopware6 DemoStore.

Whenever we call the order state transition API, on the first attempt we get a 500 error, on the second we get 200. Even if we get 500 status code in the response, we see on the admin panel that the order status gets updated. We tried different integrations, even with Admin permissions, but we still get the same error.

I'll leave here an example request:

First attempt (500 error, but order status still gets updated):

POST /api/_action/order/1fa508dcfbcf4fa2ae17a880708d5c4b/state/process

{
    "errors": [
        {
            "code": "0",
            "status": "500",
            "title": "Internal Server Error",
            "detail": "Could not find order context with referenced_order_id \"1fa508dcfbcf4fa2ae17a880708d5c4b\"."
        }
    ]
}

Second attempt (200 ok):

POST /api/_action/order/1fa508dcfbcf4fa2ae17a880708d5c4b/state/process

{
    "name": "In Bearbeitung",
    "technicalName": "in_progress",
    "stateMachineId": "829e4b7329d648e3af48c87bf3838b9b",
    "stateMachine": null,
    "fromStateMachineTransitions": null,
    "toStateMachineTransitions": null,
    "translations": null,
    "orders": null,
    "orderTransactionCaptures": null,
    "orderTransactionCaptureRefunds": null,
    "orderTransactions": null,
    "orderDeliveries": null,
    "fromStateMachineHistoryEntries": null,
    "toStateMachineHistoryEntries": null,
    "_uniqueIdentifier": "aa16871f5106458c82cc72c5aba45873",
    "versionId": null,
    "translated": {
        "name": "In Bearbeitung",
        "customFields": []
    },
    "createdAt": "2022-04-15T10:14:05.167+00:00",
    "updatedAt": null,
    "extensions": {
        "foreignKeys": {
            "apiAlias": null,
            "extensions": []
        }
    },
    "id": "aa16871f5106458c82cc72c5aba45873",
    "customFields": null
}

Some days ago we didn't have this problem. Could it be dued to some update that has been released recently on the DemoStore? Actual version is 6.4.15.0.


Solution

  • I disabled the "B2B-Suite for Shopware" extension and now the API always answers 200 at the first call. As suggested by Timo Helmke the problem is coming from this:

    Shopware\B2B\Order\Framework\OrderContextRepository::fetchOneOrderContextByReferencedOrderId

    The actual extension version is 4.6.5.