[object Object]

← back to Designerwallcoverings

TK-11644: add missing gql() error-object guard to postfix-verify + identity-fix

d8ce050eaea7c58858230084cfbc2b346a59c9f7 · 2026-09-16 14:15:10 -0700 · Steve Abrams

Both scripts dereference the bulk-op / batch-query response immediately after
calling gql() without checking for the {__err} shape gql() returns on a
non-throttled GraphQL error, so a malformed query or permission error would
crash with an opaque TypeError instead of a clear message. Added a 3-line
guard at each un-try/catch'd call site (startBulk/poll in postfix-verify,
the batch query in identity-fix). Purely additive on an error path dry-run
never exercises; both scripts' dry-run output is confirmed byte-identical
before/after (identity-fix: 5 DELETE/6 LEAVE/0 skipped; postfix-verify:
PASS, 0 survivors of 31,191). No --apply run, no behavior/API change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NbiFp4yxwRthCmDhbkwQnu

Files touched

Diff

commit d8ce050eaea7c58858230084cfbc2b346a59c9f7
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Sep 16 14:15:10 2026 -0700

    TK-11644: add missing gql() error-object guard to postfix-verify + identity-fix
    
    Both scripts dereference the bulk-op / batch-query response immediately after
    calling gql() without checking for the {__err} shape gql() returns on a
    non-throttled GraphQL error, so a malformed query or permission error would
    crash with an opaque TypeError instead of a clear message. Added a 3-line
    guard at each un-try/catch'd call site (startBulk/poll in postfix-verify,
    the batch query in identity-fix). Purely additive on an error path dry-run
    never exercises; both scripts' dry-run output is confirmed byte-identical
    before/after (identity-fix: 5 DELETE/6 LEAVE/0 skipped; postfix-verify:
    PASS, 0 survivors of 31,191). No --apply run, no behavior/API change.
    
    Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01NbiFp4yxwRthCmDhbkwQnu
---
 scripts/tk11644-identity-fix.mjs   | 1 +
 scripts/tk11644-postfix-verify.mjs | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/scripts/tk11644-identity-fix.mjs b/scripts/tk11644-identity-fix.mjs
index f01a78f..d756fa8 100644
--- a/scripts/tk11644-identity-fix.mjs
+++ b/scripts/tk11644-identity-fix.mjs
@@ -42,6 +42,7 @@ const leave   = Object.entries(PLAN).filter(([,v])=>v[0]==='LEAVE');
 
 const parts = targets.map((h,j)=>`p${j}: productByHandle(handle:${JSON.stringify(h)}){ id title vendor status descriptionHtml metafield(namespace:"global",key:"description_tag"){ id value updatedAt } }`);
 const d = await gql(`{ ${parts.join('\n')} }`);
+if (d.__err) { console.error('GraphQL error', JSON.stringify(d.__err)); process.exit(1); }
 
 const verified=[], skipped=[];
 targets.forEach((h,j)=>{
diff --git a/scripts/tk11644-postfix-verify.mjs b/scripts/tk11644-postfix-verify.mjs
index 3fe2e48..eeb6f7a 100644
--- a/scripts/tk11644-postfix-verify.mjs
+++ b/scripts/tk11644-postfix-verify.mjs
@@ -25,6 +25,7 @@ async function startBulk() {
   const q = `mutation { bulkOperationRunQuery(query: ${JSON.stringify(BULK_QUERY)}) {
     bulkOperation { id status } userErrors { field message } } }`;
   const d = await gql(q);
+  if (d.__err) { console.error('GraphQL error', JSON.stringify(d.__err)); process.exit(1); }
   const ue = d.bulkOperationRunQuery.userErrors;
   if (ue.length) { console.error('userErrors', ue); process.exit(1); }
   return d.bulkOperationRunQuery.bulkOperation.id;
@@ -33,6 +34,7 @@ async function poll() {
   const q = `{ currentBulkOperation(type: QUERY) { id status errorCode objectCount url } }`;
   for (;;) {
     const d = await gql(q);
+    if (d.__err) { console.error('\nGraphQL error', JSON.stringify(d.__err)); process.exit(1); }
     const b = d.currentBulkOperation;
     process.stderr.write(`\r  bulk ${b.status} objs=${b.objectCount}   `);
     if (b.status === 'COMPLETED') { process.stderr.write('\n'); return b; }

← 571a382 TK-00038: refresh Sanderson rollback map to match the verifi  ·  back to Designerwallcoverings  ·  TK-11644: write-ahead the rollback row before the gated dele 71fc81e →