[object Object]

← back to Goldleafwallpaper

ig-poster: loud CNCP alert on token/auth failure (no silent stop when token lapses)

018206fe4300c056dd5fc794d74e8d1a3a23a0db · 2026-08-10 12:35:23 -0700 · Steve Abrams

Files touched

Diff

commit 018206fe4300c056dd5fc794d74e8d1a3a23a0db
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Aug 10 12:35:23 2026 -0700

    ig-poster: loud CNCP alert on token/auth failure (no silent stop when token lapses)
---
 scripts/ig-poster/post-next.js | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/scripts/ig-poster/post-next.js b/scripts/ig-poster/post-next.js
index 6da950c..93acccd 100644
--- a/scripts/ig-poster/post-next.js
+++ b/scripts/ig-poster/post-next.js
@@ -130,8 +130,24 @@ async function publish(imageUrl, caption) {
       saveState(state);
       console.log('POSTED ✓ media_id', res.media_id);
     } catch (err) {
-      appendLog({ ...base, result: 'error', error: String(err.message || err) });
-      console.error('POST FAILED:', err.message || err);
+      const msg = String(err.message || err);
+      appendLog({ ...base, result: 'error', error: msg });
+      console.error('POST FAILED:', msg);
+      // If this is a token/auth failure, alert LOUDLY so the poster can never
+      // silently stop after the token expires — post a CNCP parking-lot card.
+      if (/OAuth|expired|code":?\s*190|access token|not valid|session/i.test(msg)) {
+        try {
+          await fetch('http://127.0.0.1:3333/api/parking-lot', {
+            method: 'POST', headers: { 'Content-Type': 'application/json' },
+            body: JSON.stringify({
+              title: '@goldleafwallpaper IG poster: token expired — needs re-auth',
+              note: `The 4h RML poster stopped: ${msg.slice(0, 200)}. Refresh GOLDLEAF_IG_TOKEN in scripts/ig-poster/.env (see CONNECT.md).`,
+              project: 'goldleafwallpaper',
+            }),
+          }).catch(() => {});
+        } catch (_) {}
+        console.error('ALERT: token appears expired/invalid — posted CNCP card. Re-auth needed.');
+      }
       // Do NOT advance the cursor on failure — retry the same SKU next tick.
       console.log('cost: $0 (local; Graph publish is free)');
       process.exit(2);

← 9c92498 ig-poster: poll media container status_code until FINISHED b  ·  back to Goldleafwallpaper  ·  ig-poster: crop the Phillipe Romano header banner off each i 49ec03e →