Skip to content

fix(instagram): fail cleanly when a post has no media - #145

Closed
murtaja1 wants to merge 1 commit into
brightbeanxyz:mainfrom
Murtaja-Adnan:pr/instagram-media-guard
Closed

fix(instagram): fail cleanly when a post has no media#145
murtaja1 wants to merge 1 commit into
brightbeanxyz:mainfrom
Murtaja-Adnan:pr/instagram-media-guard

Conversation

@murtaja1

Copy link
Copy Markdown

A media-less Instagram publish currently crashes with a raw IndexError (media_urls[0]) — and a media-less CAROUSEL is worse: it creates an empty container and spins in _wait_for_container until the processing timeout. Both burn the retry schedule on an input no retry can fix.

Hit in production twice: a text-only post routed to Instagram ('list index out of range' in the publish log ×4), and again when a post's attachment was removed while a retry was pending.

Fix: raise a non-retryable PublishError ('Instagram requires at least one image or video — attach media to this post.') before any API call.

Tested: three new tests (IMAGE/REEL/CAROUSEL) assert the clean error and that no API request is made; full tests/providers/test_instagram.py passes. Side effect: the carousel test case dropped from a 2-minute wait-loop to instant.

A media-less Instagram publish crashed with a raw IndexError (or an empty
carousel stuck in the container wait loop) and burned the retry schedule.
Raise a non-retryable PublishError before any API call instead.
@murtaja1
murtaja1 requested a review from JanSchm as a code owner August 11, 2026 12:52
@Murtaja-Adnan Murtaja-Adnan closed this by deleting the head repository Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants