← back to York Reprice 2026 08
cadence: fix swallowed-SQL-error false-zero — onboard-ready was 0, is really 822
27f6dd03d74d62bba4abaf1885c1466b4b5057cd · 2026-07-12 12:06:16 -0700 · Steve
The onboardCand query is multi-line; q() ran it via 'psql -c "<sql>"' which
throws 'invalid command \n' on embedded newlines. That throw was caught by the
query's try/catch and returned [], so onboardReady reported 0 for months while
822 imaged+settlement-clear New SKUs sat genuinely un-onboarded. Route q()
through a temp .sql file + -f so multi-line SQL is safe. Verified: onboard-ready 0 -> 822.
Files touched
M cadence/york-cadence.mjs
Diff
commit 27f6dd03d74d62bba4abaf1885c1466b4b5057cd
Author: Steve <steve@designerwallcoverings.com>
Date: Sun Jul 12 12:06:16 2026 -0700
cadence: fix swallowed-SQL-error false-zero — onboard-ready was 0, is really 822
The onboardCand query is multi-line; q() ran it via 'psql -c "<sql>"' which
throws 'invalid command \n' on embedded newlines. That throw was caught by the
query's try/catch and returned [], so onboardReady reported 0 for months while
822 imaged+settlement-clear New SKUs sat genuinely un-onboarded. Route q()
through a temp .sql file + -f so multi-line SQL is safe. Verified: onboard-ready 0 -> 822.
---
cadence/york-cadence.mjs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/cadence/york-cadence.mjs b/cadence/york-cadence.mjs
index 26bdc3d..12c559f 100644
--- a/cadence/york-cadence.mjs
+++ b/cadence/york-cadence.mjs
@@ -15,7 +15,11 @@ const SHOP='designer-laboratory-sandbox.myshopify.com',VER='2024-10';
const TOKEN=(fs.readFileSync(process.env.HOME+'/Projects/secrets-manager/.env','utf8').match(/^SHOPIFY_ADMIN_TOKEN=(.+)$/m)||[])[1]?.trim();
const URL=`https://${SHOP}/admin/api/${VER}/graphql.json`;
const PG='PGPASSWORD=DW2024SecurePass /opt/homebrew/opt/postgresql@14/bin/psql -h 127.0.0.1 -U dw_admin -d dw_unified -tA -F\'\x1f\' -c';
-const q=sql=>execSync(`${PG} ${JSON.stringify(sql)}`,{encoding:'utf8'}).trim();
+// multi-line SQL breaks `psql -c "<sql>"` ("invalid command \n") — the onboardCand query is
+// multi-line and was silently throwing into a catch{}, falsely returning onboardReady=0 for
+// MONTHS. Route every query through a temp .sql file + `-f` so multi-line SQL is safe.
+// (All cadence queries concat_ws(chr(31),…) into ONE column, so -F is unnecessary.)
+const q=sql=>{fs.writeFileSync('/tmp/_yc_q.sql',sql);return execSync(`PGPASSWORD=DW2024SecurePass /opt/homebrew/opt/postgresql@14/bin/psql -h 127.0.0.1 -U dw_admin -d dw_unified -tA -f /tmp/_yc_q.sql`,{encoding:'utf8'}).trim();};
const sleep=ms=>new Promise(r=>setTimeout(r,ms));
const gql=async(query,v)=>{for(let a=0;a<8;a++){let j;try{const r=await fetch(URL,{method:'POST',headers:{'X-Shopify-Access-Token':TOKEN,'Content-Type':'application/json'},body:JSON.stringify({query,variables:v})});j=await r.json();}catch(e){await sleep(1500*(a+1));continue;}if(j.errors){if(JSON.stringify(j.errors).includes('THROTTLED')){await sleep(2000*(a+1));continue;}throw new Error(JSON.stringify(j.errors));}const t=j.extensions?.cost?.throttleStatus;if(t&&t.currentlyAvailable<300)await sleep(1500);return j.data;}throw new Error('retries');};
const norm=s=>String(s||'').toUpperCase().trim();
← 9ee51a3 cadence: dual image-drawer onboard lookup + naturals-aware d
·
back to York Reprice 2026 08
·
cadence: add settlement-review worksheet (513) + image-integ 4be4147 →