gitroomhq/postiz-app · error · BadRequestException

Failed to update the post

Error message

Failed to update the post

What it means

After validation, the update is persisted via updatePost on the repository (with the group kept stable for calendar grouping). If the repository returns a falsy result — typically the underlying update affected no rows — the service surfaces 'Failed to update the post'.

Source

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

          label: t.tag.name,
        })),
        posts: [
          {
            integration,
            group: root.group,
            settings: mergedSettings,
            value,
          },
        ],
      } as any,
      creationMethod,
      // Keep the group stable: a client may have the calendar open while the
      // settings are updated out of band, and the calendar links posts by group.
      true
    );

    if (!output) {
      throw new BadRequestException('Failed to update the post');
    }

    return {
      postId: output.postId,
      publishDate: date,
    };
  }

  async separatePosts(content: string, len: number) {
    return this._openaiService.separatePosts(content, len);
  }

  async changeState(id: string, state: State, err?: any, body?: any) {
    return this._postRepository.changeState(id, state, err, body);
  }

  async changePostStatus(
    orgId: string,

View on GitHub (pinned to 0f1647f749)

Solutions

  1. Refetch the post by id; if it's gone, refresh the calendar and create a new post
  2. Retry the update once after re-fetching fresh post data
  3. Check backend logs for a concurrent delete or scheduler mutation on the same post id
  4. Avoid holding editor sessions open across long periods on soon-to-change posts

Example fix

// before
await updatePost(orgId, postId, body); // once, assume success
// after
let result = await updatePost(orgId, postId, body).catch(() => null);
if (!result) {
  const fresh = await getPostById(orgId, postId);
  if (fresh) result = await updatePost(orgId, postId, body);
}
Defensive patterns

Strategy: retry

Validate before calling

const post = await getPostById(orgId, postId);
if (!post) { await refreshCalendar(); return; }

Try / catch

try {
  await updatePost(orgId, postId, body);
} catch (e) {
  if (/Failed to update the post/.test(String(e?.response?.message ?? e))) {
    const fresh = await getPostById(orgId, postId);
    if (fresh) await updatePost(orgId, postId, body); // one retry after refetch
    else await refreshCalendar();
  } else throw e;
}

Prevention

When it happens

Trigger: Updating a post id that was deleted between the initial fetch and the repository write, or a repository-level failure/rollback that returns null instead of throwing.

Common situations: Concurrent deletion by another team member mid-edit; race with the scheduler changing the post; Prisma update matching zero records; transient DB issues.

Related errors


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