WooCommerce REST API allows duplicate SKUs when SKU is passed via `meta_data`

I create products through the WooCommerce REST API (POST /wp-json/wc/v3/products) and pass the SKU inside meta_data as {"key": "_sku", "value": "1234567890"}. I was able to create multiple products with the same SKU. Shouldn't the duplicate SKU be rejected?

This was a real bug: when you send _sku inside meta_data, it bypassed WC_Product::set_sku() and went through MetaDataUtil::update() instead, so the SKU uniqueness check (wc_product_has_unique_sku()) never ran. It was fixed by PR #31168. On a current WooCommerce version, the same request now returns a 400 product_invalid_sku error on the second product with the same SKU, and only one product persists. The recommended practice anyway: send sku as the top-level field, not inside meta_data, since top-level always goes through the proper setter.

Source: https://github.com/woocommerce/woocommerce/issues/29286