gitroomhq/postiz-app · error · BadBody

The uploaded media expired before the post was published, pl

Error message

The uploaded media expired before the post was published, please post again

What it means

Mastodon returns HTTP 422 when posting a status that references media attachments that have expired (Mastodon deletes unprocessed/unattached uploads after a TTL, historically ~1 day but sometimes minutes for unprocessed media). Since the attachment is gone server-side, the post cannot be created and must be re-submitted.

Source

Thrown at libraries/nestjs-libraries/src/integrations/social/mastodon.provider.ts:338

          this.identifier,
          await response.text().catch(() => '{}'),
          '{}'
        );
      }

      if (response.status === 404 || response.status === 410) {
        // The media GET only sees UNATTACHED media: after a finalize whose
        // outcome was lost, an already-published status makes its media 404
        // here. Never conclude "expired, post again" (that instruction is the
        // duplicate path) - keep checking the remaining media (a later 206
        // still wins) and let the idempotent finalize either dedupe into the
        // existing status or get Mastodon's verdict.
        await response.text().catch(() => '');
        continue;
      }

      if (response.status === 422) {
        throw new BadBody(
          this.identifier,
          await response.text().catch(() => '{}'),
          '{}',
          'The uploaded media expired before the post was published, please post again'
        );
      }

      await response.text().catch(() => '');

      if (response.status !== 200) {
        // Unknown answer on a read-only check: treat as transient.
        return { status: 'pending', pendingData };
      }
    }

    return { status: 'ready', pendingData };
  }

View on GitHub (pinned to 0f1647f749)

Solutions

  1. Retry/re-post now: the workflow will re-upload the media and create a fresh attachment
  2. For long-delayed posts, prefer the flow that uploads media close to publish time (keep the post pending rather than uploading early)
  3. If it happens on immediate posts, check for delays between upload and publish steps in custom workflows
Defensive patterns

Strategy: retry

Try / catch

if (/media expired/.test(err.message)) { /* re-post now re-uploads media */ }

Prevention

When it happens

Trigger: A post was scheduled far enough ahead that the uploaded Mastodon media attachment expired before checkPostStatus/publish ran; the POST /api/v1/statuses call gets 422.

Common situations: Long-scheduled posts with media, posts left pending for hours/days, retries of very old pending posts.

Related errors


AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27). Data as JSON: /api/errors/dfedcdcf1a0111ab. Report an issue: GitHub.