← back to Norma
IG poster: poll container to FINISHED for images too (fixes 'Media ID is not available'); verified live post to @patterndesignlab
57ebb5d8a4586f5dcf586f7cb598b8e2ef36058f · 2026-08-10 11:59:05 -0700 · Steve
Files touched
M agents/instagram-agent/post-to.js
Diff
commit 57ebb5d8a4586f5dcf586f7cb598b8e2ef36058f
Author: Steve <steve@designerwallcoverings.com>
Date: Mon Aug 10 11:59:05 2026 -0700
IG poster: poll container to FINISHED for images too (fixes 'Media ID is not available'); verified live post to @patterndesignlab
---
agents/instagram-agent/post-to.js | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/agents/instagram-agent/post-to.js b/agents/instagram-agent/post-to.js
index 16d5d77..ce5bf4f 100644
--- a/agents/instagram-agent/post-to.js
+++ b/agents/instagram-agent/post-to.js
@@ -72,15 +72,21 @@ async function publishOne(acct, opts) {
// Step 1: create container
const c = await graph(host, ver, `${id}/media`, container);
- // Step 2: video kinds need processing time before publish
- if (kind !== 'IMAGE') {
- for (let i = 0; i < 30; i++) {
+ // Step 2: ALL kinds need to reach FINISHED before publish — images fetch the
+ // remote URL first (IN_PROGRESS for ~1 poll); video kinds transcode (longer).
+ // Publishing early yields "Media ID is not available".
+ {
+ const tries = kind === 'IMAGE' ? 15 : 45;
+ const delay = kind === 'IMAGE' ? 2000 : 4000;
+ let finished = false;
+ for (let i = 0; i < tries; i++) {
const s = await fetch(`${host}/${ver}/${c.id}?fields=status_code&access_token=${encodeURIComponent(token)}`);
const sj = await s.json();
- if (sj.status_code === 'FINISHED') break;
+ if (sj.status_code === 'FINISHED') { finished = true; break; }
if (sj.status_code === 'ERROR') throw new Error(`container processing error for @${acct.handle}`);
- await new Promise((res) => setTimeout(res, 4000));
+ await new Promise((res) => setTimeout(res, delay));
}
+ if (!finished) throw new Error(`container never reached FINISHED for @${acct.handle}`);
}
// Step 3: publish
const pub = await graph(host, ver, `${id}/media_publish`, { creation_id: c.id, access_token: token });
← 6b3ec24 IG multi-account posting: registry + resolver + post-to CLI
·
back to Norma
·
IG: linking checklist for the 45 unlinked Pages (tiered by b 0daec04 →