How to safely update custom fields (keeping other custom field values)?

We are updating some products custom fields via the productRepositoryupsert method:

 $productdata = [// ... 'customFields' =\> [ 'productLine' =\> 'foo', 'setConsists' =\> 'bar'] // ... ];$this-\>productRepository-\>upsert( [$productdata], \Shopware\Core\Framework\Context::createDefaultContext() );

Will other custom field values be deleted when updating the product like this (which is my current assumption tracking down a nasty bug)?

No, other custom fields data will not be affected by this. Only those, that you specifically mention (in your case productLine and setConsists), get changed.