Fix daily content cron: IG mirror silently failing since 2026-05-27#151
Draft
neverpeakev wants to merge 2 commits into
Draft
Fix daily content cron: IG mirror silently failing since 2026-05-27#151neverpeakev wants to merge 2 commits into
neverpeakev wants to merge 2 commits into
Conversation
The auth/page-context catch in /api/social/ig-mirror silently returned 200 with no console.error and no DB update, so a Meta scope/token regression on 2026-05-27 went unnoticed for 42 days. Every daily FB post since then landed as fb_published with ig_published_at=null and no error_message — the routine health check had nothing to grab onto. - console.error at every failure branch so Vercel runtime logs surface the exact Meta response. - When fetchPageContext throws, mark each pending row as ig_failed with the error message so the DB carries the diagnosis and rows stop re-queuing forever. Immediate operator action after merge: check the next ig_failed row's error_message for the Meta error and re-issue META_MARKETING_API_TOKEN with instagram_basic + instagram_content_publish scopes.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Diagnosis
Routine health check on 2026-07-08 found today's FB post published cleanly (
gen-2026-07-08-p9hrc, fb_post_id1086292991223812_122116418852989743) but the IG mirror row still showsstatus='fb_published'withig_media_id=nullanderror_message=null. The IG cron ran at 14:15:08 UTC and returned 200 with no log output.Pulling recent history from
generated_posts:fb_publishedwithig_published_at=null,error_message=null. Ten rows total sitting idle.ig_failedwith Meta'scode=100, error_subcode=33, "Authorization Error"— the token needed re-authorization or a missing scope.What happened: after 2026-05-27, the failure point moved from inside the per-row
publishToIgcall (which correctly caught + markedig_failed) to insidefetchPageContext, which runs once before the row loop. That catch block returned 200 withok:falsein the body but wrote noconsole.errorand did not touch any row — so 42 days of failures were invisible to both Vercel runtime logs and the DB. This routine check only caught it because it cross-referencedig_published_athistory.Almost certainly the same underlying Meta scope/token regression as the late-May
ig_failedrows — the page-token likely lostinstagram_basicand/orinstagram_content_publishwhen the system-user token was last rotated — but the observability gap prevented anyone from noticing.Changes
app/api/social/ig-mirror/route.tsconsole.errorat both failure branches (auth/page-contextand the per-row publish catch) so future Meta errors surface in Vercel runtime logs.fetchPageContextthrows, mark each row inpendingasig_failedwith the error message. Previously the rows were left untouched and re-queued indefinitely, so the failure was doubly hidden (no log, no DB trace). Now the DB carries the diagnosis and the next routine run can greperror_message.Immediate follow-up (operator)
After merge, the next 14:15 UTC cron will mark today's stuck row (and any others) as
ig_failedwith the actual Meta response inerror_message. Read that error, then either:META_MARKETING_API_TOKENwithinstagram_basic+instagram_content_publishscopes, orOnce the token is fixed, the 10 stuck rows can be backfilled by clearing their
statusback tofb_published(they're alreadyig_failedafter this PR runs once, so thelistPendingIgMirrorfilter would skip them).Test plan
[ig-mirror] auth/page-context failed:with the Meta error body.fb_published→ig_failedwith a populatederror_message.ig_publishedwith anig_media_id.Generated by Claude Code