[object Object]

← back to Designer Wallcoverings

TK-11418: stamp shopify_product_id by primary key, not by ambiguous dw_sku

020aa93c2e0208c1aa66fd67e89f850806741658 · 2026-09-10 12:55:51 -0700 · Steve Abrams

STEP 8 of launch-test ran `UPDATE "${catTable}" SET shopify_product_id = $1
WHERE dw_sku = $2`. On the shared `vendor_catalog` that predicate is ambiguous — 1,148
dw_sku values are held by MORE THAN ONE vendor_code — so a single push also stamped other
vendors' rows, marking them already-on-Shopify when they were not and silently suppressing
them from future imports. (dw_sku is also unindexed on that ~292k-row table, so it was a
full seq scan.)

Selects `id` and stamps by primary key instead. Verified additive-safe: the product row is
only ever accessed field-by-field in this handler — no spread, no Object.keys/entries, no
JSON.stringify of the whole row — so the extra column cannot leak into a Shopify payload.

Completes the TK-11418 pair with cfff3faa, which scoped the STEP 1 selection.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Files touched

Diff

commit 020aa93c2e0208c1aa66fd67e89f850806741658
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Thu Sep 10 12:55:51 2026 -0700

    TK-11418: stamp shopify_product_id by primary key, not by ambiguous dw_sku
    
    STEP 8 of launch-test ran `UPDATE "${catTable}" SET shopify_product_id = $1
    WHERE dw_sku = $2`. On the shared `vendor_catalog` that predicate is ambiguous — 1,148
    dw_sku values are held by MORE THAN ONE vendor_code — so a single push also stamped other
    vendors' rows, marking them already-on-Shopify when they were not and silently suppressing
    them from future imports. (dw_sku is also unindexed on that ~292k-row table, so it was a
    full seq scan.)
    
    Selects `id` and stamps by primary key instead. Verified additive-safe: the product row is
    only ever accessed field-by-field in this handler — no spread, no Object.keys/entries, no
    JSON.stringify of the whole row — so the extra column cannot leak into a Shopify payload.
    
    Completes the TK-11418 pair with cfff3faa, which scoped the STEP 1 selection.
    
    Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---
 DW-Agents/vendor-command-center/server.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/DW-Agents/vendor-command-center/server.js b/DW-Agents/vendor-command-center/server.js
index 77933003..71e2655b 100644
--- a/DW-Agents/vendor-command-center/server.js
+++ b/DW-Agents/vendor-command-center/server.js
@@ -1138,6 +1138,7 @@ app.post('/api/launch-test', async (req, res) => {
       const colorCol = colSet.has('color_name') ? 'color_name' : "''";
 
       const selectCols = [
+        'id',
         'mfr_sku', `${nameCol} as pattern_name`, `${colorCol} as color_name`, 'dw_sku',
         colSet.has('width') ? 'width' : "'' as width",
         colSet.has('image_url') ? 'image_url' : "'' as image_url",
@@ -1494,7 +1495,11 @@ app.post('/api/launch-test', async (req, res) => {
 
       // ── STEP 8: Update catalog with shopify_product_id ──
       try {
-        await pool.query(`UPDATE "${catTable}" SET shopify_product_id = $1 WHERE dw_sku = $2`, [String(shopifyProductId), p.dw_sku]);
+        // TK-11418: stamp by PRIMARY KEY, not by dw_sku. On the shared `vendor_catalog`,
+        // 1,148 dw_sku values are held by MORE THAN ONE vendor_code, so `WHERE dw_sku = $2`
+        // also stamped other vendors' rows — marking them already-on-Shopify when they are
+        // not, and silently suppressing them from future imports. `id` is selected above.
+        await pool.query(`UPDATE "${catTable}" SET shopify_product_id = $1 WHERE id = $2`, [String(shopifyProductId), p.id]);
       } catch (e) {
         console.error('[VCC] Catalog update error for', p.dw_sku, e.message);
       }

← e252ac31 TK-11400: fix false-success in inventory-set-2026-newest swe  ·  back to Designer Wallcoverings  ·  TK-11400: inventory sweep prefers the full-access credential 55c6546f →