Zend certified PHP/Magento developer

Updating products in bulk with async endpoint fails with error getProductFromLocalCache() must be of the type string, null given

I’m trying to update multiple items as a batch in Version 2.4.3-p1

    $productUpdates = [];
    foreach ($updates as $magento_sku => $data) {
        $productUpdates[] = [
            'sku' => $magento_sku,
            'product' => [
                'price' => $data['price'],
                'extension_attributes' => [
                    'stock_item' => [
                    'qty' => $data['qty']
                ]
            ]
        ]
    ];




$url = 'https://example.com/rest/default/async/bulk/V1/products/bySku';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($productUpdates));
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
curl_close($ch);

echo $response;

The response seems fine:

{"bulk_uuid":"ec459e2a-1989-4852-b0d4-f84321199013","request_items":[{"id":0,"data_hash":"64273b9876093e45c54b36c78efba73b2a17de3982f15d787bcbd49767fdfe6c","status":"accepted"}],"errors":false}

The content is sent to RabbitMQ where I can see its properly received but the data does not get updated as expected.

In fact, the status of the UUID remains in 4 (meaning ‘open’)

(
    [operations_list] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 0
                    [status] => 4
                    [result_message] =>
                    [error_code] =>
                )

        )

    [user_type] => 2
    [bulk_id] => ec459e2a-1989-4852-b0d4-f84321199013
    [description] => Topic async.magento.catalog.api.productrepositoryinterface.save.put
    [start_time] => 2023-09-01 18:54:07
    [user_id] => 10
    [operation_count] => 1
)

Running php bin/magento queue:consumers:start async.operations.all at the same time as the message is being processed shows:

Argument 1 passed to MagentoCatalogModelProductRepository::getProductFromLocalCache() must be of the type string, null given, called in /home/example/deploy/releases/20230519090918/vendor/magento/module-catalog/Model/ProductRepository.php on line 284#

I can see the content sent to RabbitMQ and it appears to be correct. The SKU certainly exists, so what exactly is being passed as null?

Thank you.