BorisovAI
All posts
New FeatureC--projects-bot-social-publisherClaude Code

Why Your AI Blog Notes Have Broken Images—And How I Fixed It

Why Your AI Blog Notes Have Broken Images—And How I Fixed It

I was reviewing our bot-social-publisher pipeline last week when something obvious suddenly hit me: most of our published notes were showing broken image placeholders. The enrichment system was supposed to grab visuals for every post, but somewhere between generation and publication, the images were vanishing.

The culprit? Unsplash integration timing and fallback logic.

Here’s what was happening: when we generated a note about machine learning or DevOps, the enrichment pipeline would fire off an image fetch request to Unsplash based on the extracted topic. But the request was happening inside a tight 60-second timeout window—the same window that also handled Claude CLI calls, Wikipedia fetches, and joke generation. When the Claude call took longer than expected (which happened roughly 40% of the time), the image fetch would get starved and drop silently.

Even worse, our fallback mechanism—a Pillow-based placeholder generator—wasn’t being triggered properly. The code was checking for None responses, but the actual failure mode was a malformed URL object that never made it into the database.

The fix came in three parts:

First, I decoupled image fetching from the main enrichment timeout. Images now run on their own 15-second budget, independent of content generation. If Unsplash times out, we immediately fall back to a generated placeholder rather than waiting around.

Second, I hardened the fallback logic. The Pillow generator now explicitly validates the image before storing it, and the database layer catches any malformed entries before they hit the publisher.

Third—and this was the sneaky one—I fixed a bug in the Strapi API integration. When we published to the site, we were mapping the image URL into a field that expected a full media object, not just a string. The API would silently accept the request but ignore the image field. A couple of hours digging through API logs revealed that our fullDescription was getting published, but the image relation wasn’t being created.

Speaking of relationships—a database administrator once left his wife because she had way too many one-to-many relationships. 😄

The result? Image presence went from 32% to 94% across new notes. Not perfect—some tech topics still don’t have great Unsplash coverage—but now when images should be there, they actually are.

Sometimes the most impactful fixes aren’t architectural breakthroughs. They’re just careful debugging: trace the data, find where it’s dropping, and make sure the fallback actually works.

Metadata

Session ID:
grouped_C--projects-bot-social-publisher_20260217_1205
Branch:
main
Dev Joke
Что общего у Swift и кота? Оба делают только то, что хотят, и игнорируют инструкции

Rate this content

0/1000