gitroomhq/postiz-app · error · BadBody

Reddit rejected the post to r/${postData.sr}: ${all.json.err

Error message

Reddit rejected the post to r/${postData.sr}: ${all.json.errors.map((e: any[]) => e?.[1] || e?.[0] || '').join(', ')}

What it means

Reddit's submit endpoint returns HTTP 200 with a json.errors array when it rejects a submission (RATELIMIT, NO_TEXT, TOO_OLD, QUARANTINE, etc.). finalizePost checks this array and throws BadBody listing each error code/message so the real reason surfaces instead of a later unknown-outcome failure.

Source

Thrown at libraries/nestjs-libraries/src/integrations/social/reddit.provider.ts:522

      text: data.message,
      sr: value.subreddit.replace('/r/', '').toLowerCase(),
    };

    const all = await (
      await this.fetch('https://oauth.reddit.com/api/submit', {
        method: 'POST',
        headers: {
          Authorization: `Bearer ${accessToken}`,
          'Content-Type': 'application/x-www-form-urlencoded',
        },
        body: new URLSearchParams(postData),
      })
    ).json();

    // Reddit rejects submissions with a 200 and an errors array: surface the
    // real reason instead of failing later with an unknown outcome.
    if (all?.json?.errors?.length) {
      throw new BadBody(
        this.identifier,
        JSON.stringify(all),
        Buffer.from('{}'),
        `Reddit rejected the post to r/${postData.sr}: ${all.json.errors
          .map((e: any[]) => e?.[1] || e?.[0] || '')
          .join(', ')}`
      );
    }

    // Self/link posts answer with the created post directly.
    if (all?.json?.data?.id) {
      data.results = [
        ...data.results,
        {
          postId: all.json.data.id,
          releaseURL:
            all.json.data.url || `https://www.reddit.com/r/${postData.sr}`,
        },

View on GitHub (pinned to 0f1647f749)

Solutions

  1. Read the error codes in the message and address the specific one (wait for RATELIMIT, fix fields for NO_TEXT/TOO_OLD)
  2. Verify the account is allowed to post to r/{sr} (age, karma, bans)
  3. Slow down scheduled Reddit posts to avoid RATELIMIT
  4. Re-authenticate if the error indicates session/token problems
Defensive patterns

Strategy: try-catch

Validate before calling

if (!content?.trim()) throw new Error('Post text required for Reddit');

Try / catch

catch (e) { if (/Reddit rejected the post/.test(e.message)) { const codes = e.message.match(/RATELIMIT|NO_TEXT|TOO_OLD/g); /* branch on codes */ } }

Prevention

When it happens

Trigger: POST to api/submit succeeds at HTTP level but all.json.errors is non-empty — posting too fast (RATELIMIT), missing/invalid fields, banned from subreddit, invalid captcha/redirect, etc.

Common situations: Posting repeatedly from the same account (rate limit), new accounts posting to restricted subreddits, deleted/invalid sr, or shadowbanned accounts.

Related errors


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