gitroomhq/postiz-app · error · BadRequestException

This post was already published on ${dayjs .utc(post.publi

Error message

This post was already published on ${dayjs
  .utc(post.publishDate)
  .format('YYYY-MM-DD HH:mm')} UTC. Saving it this way would publish it again to ${
  post.integration?.providerIdentifier || 'the channel'
}. To edit without republishing, ${howToUpdate}. To intentionally publish again, pass republish: true.

What it means

Guard against accidental republication: saving a post whose state is already PUBLISHED through the create/normal save path would push it to the channel again. The error tells you to either use the update flow (type 'update' / action 'update') or explicitly opt in with republish: true.

Source

Thrown at libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts:891

    }
    return '';
  }

  // A schedule-type save targeting an already-PUBLISHED post republishes it to
  // the platform: require the explicit `republish` opt-in instead. The message
  // doubles as the confirmation dialog for API/MCP automation.
  private guardAgainstRepublish(
    post: { state: State; publishDate: Date; integration?: { providerIdentifier: string } } | null,
    source: 'createPost' | 'changeDate'
  ) {
    if (post?.state !== 'PUBLISHED') {
      return;
    }

    const howToUpdate =
      source === 'createPost' ? `use type 'update'` : `use action 'update'`;

    throw new BadRequestException(
      `This post was already published on ${dayjs
        .utc(post.publishDate)
        .format('YYYY-MM-DD HH:mm')} UTC. Saving it this way would publish it again to ${
        post.integration?.providerIdentifier || 'the channel'
      }. To edit without republishing, ${howToUpdate}. To intentionally publish again, pass republish: true.`
    );
  }

  async createPost(
    orgId: string,
    body: CreatePostDto,
    creationMethod: CreationMethod,
    keepGroup = false
  ): Promise<any[]> {
    const postList = [];
    for (const post of body.posts) {
      if (
        (body.type === 'schedule' || body.type === 'now') &&

View on GitHub (pinned to 0f1647f749)

Solutions

  1. Switch the request to the update flow: set type: 'update' (or action: 'update') in the payload
  2. If a genuine republication is intended, pass republish: true in the body
  3. Debounce/disable the save button to prevent duplicate submissions
  4. Check the post's state via getPostById before saving and route published posts to the editor

Example fix

// before
await createPost(orgId, { ...body, posts: body.posts }); // post already PUBLISHED
// after
await createPost(orgId, { ...body, type: 'update', posts: body.posts });
// or intentional repost:
await createPost(orgId, { ...body, republish: true, posts: body.posts });
Defensive patterns

Strategy: validation

Validate before calling

const post = await getPostById(orgId, postId);
const isPublished = post?.state === 'PUBLISHED';
await createPost(orgId, { ...body, ...(isPublished && !intendedRepublish ? { type: 'update' } : {}), republish: intendedRepublish || undefined });

Try / catch

try {
  await createPost(orgId, body);
} catch (e) {
  if (/already published/.test(String(e?.response?.message ?? e))) {
    await createPost(orgId, { ...body, type: 'update' });
  } else throw e;
}

Prevention

When it happens

Trigger: Calling createPost (or an equivalent save) with the id of a post whose state is PUBLISHED, without republish: true; e.g. a calendar UI re-saving an already-sent post.

Common situations: Retry logic resubmitting an already-succeeded create; editing UI defaulting to create mode for existing published posts; double-click submissions; API consumers unaware the post already went out.

Related errors


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