Handling partial failures

View .md

When a post reaches some accounts but not others, here is how to detect it and recover.


What partial means

A publish job fans out to every account in account_ids. If at least one account succeeds and at least one fails, the job status is partial. The post is live where it succeeded; you only need to deal with the accounts that failed.

Inspecting per account results

Read the job in the publish history. Each entry has a results array with one item per account:

JSON
{  "status": "partial",  "results": [    { "account_id": "acc_x", "platform": "x", "status": "published", "platform_post_id": "1890..." },    {      "account_id": "acc_ig",      "platform": "instagram",      "status": "failed",      "error_code": "unsupported_media_format",      "error_message": "Instagram image publishing supports JPEG files only."    }  ]}

error_code is stable and safe to branch on in code; error_message is for humans and logs.

Recovering

  1. Filter results to the accounts where status is failed.
  2. Use error_code to decide: fix the input (for example convert the image to JPEG) or, for a transient error, retry.
  3. Re-publish only to the failed accounts, not the whole set, so you do not duplicate the post where it already succeeded.
JavaScript
const failed = job.results.filter((r) => r.status === "failed");
if (failed.length) {
  await publish({
    accountIds: failed.map((r) => r.account_id),
    text: job.text,
    mediaUrls: job.media_urls,
  });
}

For the full error model, see Errors.