Cross-posting to social media: a deep dive into state, idempotency, and broken Cyrillic
LiveDune
An engineer shares lessons from automating cross-posting of blog articles to social networks. The task turned out to be a complex pipeline with multiple failure zones, requiring careful handling of timeouts, image formats, API responses, and text encoding. Key takeaways include separating package, transport, and QC, and using hard gates for verification.
The author was tasked to automate cross-posting of blog articles to social networks, including generating short announcements, rewriting content for Dzen and Spark, attaching images, setting UTM tags, and publishing to Telegram and other channels. Initial attempts with an AI agent revealed many pitfalls: Telegram posts actually went through but the CLI returned a timeout error, Markdown links visually merged with text, WebP images became huge PNGs, VK hit anti-bot checks, OK lost preview cards, and Google Docs contained corrupted characters (U+FFFD). The author realized that cross-posting is not a single operation but a pipeline with independent failure zones, and structured it as source → content package → media resolution → transport → verification → report. Key insights: a timeout does not mean the post wasn't published, so retries must be based on actual verification; browser automation is unreliable and should be a fallback; API responses like HTTP 201 do not guarantee delivery, so each platform must have a verified final state; images need proper validation and resolution (e.g., WebP to PNG conversion degraded an asset tenfold); and text encoding corruption (U+FFFD) must be caught with hard gates, as it cannot be fixed with a simple replace. For rewriting, the author used full HTML with sanitation rather than JSON to avoid CTA and banners, and limited processing to one fresh article per run.
- Abbreviations
- CLI = Command Line Interface — интерфейс командной строки
- QC = Quality Control — контроль качества
- API = Application Programming Interface — программный интерфейс приложения
- MIME = Multipurpose Internet Mail Extensions — многоцелевые расширения интернет-почты
- URL = Uniform Resource Locator — единый указатель ресурса
- HTML = HyperText Markup Language — язык гипертекстовой разметки
- HTTP = HyperText Transfer Protocol — протокол передачи гипертекста
- CDN = Content Delivery Network — сеть доставки контента
- JSON = JavaScript Object Notation — нотация объектов JavaScript
- CSV = Comma-Separated Values — значения, разделённые запятыми
- CTA = Call to Action — призыв к действию
- H2 = Heading level 2 — заголовок второго уровня
- H3 = Heading level 3 — заголовок третьего уровня
Source: Habr — хаб ИИ —
original
