← back to Grassclothwallpaper
Guard against non-array Supabase fetch responses in crop/color scripts
84ebfa2262dadaa7eadbecbec8da1f87df49ae97 · 2026-05-18 20:33:29 -0700 · SteveStudio2
Files touched
M extract-and-save-colors.jsM force-crop-all-grs.jsM process-grs-20385-first.js
Diff
commit 84ebfa2262dadaa7eadbecbec8da1f87df49ae97
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date: Mon May 18 20:33:29 2026 -0700
Guard against non-array Supabase fetch responses in crop/color scripts
---
extract-and-save-colors.js | 5 +++++
force-crop-all-grs.js | 11 +++++++++++
process-grs-20385-first.js | 11 +++++++++++
3 files changed, 27 insertions(+)
diff --git a/extract-and-save-colors.js b/extract-and-save-colors.js
index abd83b7..ea6e92a 100644
--- a/extract-and-save-colors.js
+++ b/extract-and-save-colors.js
@@ -26,6 +26,11 @@ async function extractAllColors() {
}
const products = await response.json();
+
+ if (!Array.isArray(products)) {
+ throw new Error(`Unexpected response from Supabase: ${JSON.stringify(products)}`);
+ }
+
const productsWithImages = products.filter(p =>
p.image_url && p.image_url.includes('supabase.co/storage')
);
diff --git a/force-crop-all-grs.js b/force-crop-all-grs.js
index 9cee837..5fc16e5 100644
--- a/force-crop-all-grs.js
+++ b/force-crop-all-grs.js
@@ -112,7 +112,18 @@ async function forceCropAllGRS() {
}
);
+ if (!response.ok) {
+ console.error(`Failed to fetch products: ${response.status} ${response.statusText}`);
+ return;
+ }
+
const products = await response.json();
+
+ if (!Array.isArray(products)) {
+ console.error('Unexpected response from Supabase:', products);
+ return;
+ }
+
console.log(`Found ${products.length} GRS products\n`);
console.log('STARTING FORCED UPDATE OF ALL PRODUCTS...\n');
diff --git a/process-grs-20385-first.js b/process-grs-20385-first.js
index dccd529..5ca7a5e 100644
--- a/process-grs-20385-first.js
+++ b/process-grs-20385-first.js
@@ -196,7 +196,18 @@ async function processAllGRSProducts() {
}
);
+ if (!response.ok) {
+ console.error(`Failed to fetch products: ${response.status} ${response.statusText}`);
+ return;
+ }
+
const products = await response.json();
+
+ if (!Array.isArray(products)) {
+ console.error('Unexpected response from Supabase:', products);
+ return;
+ }
+
console.log(`Found ${products.length} GRS products total\n`);
let processedCount = 0;
← 6067fde Harden gitignore (bak/output artifacts) and add null/error g
·
back to Grassclothwallpaper
·
(newest)