gitroomhq/postiz-app · error · BadRequestException
This id belongs to a comment, pass the id of the main post
Error message
This id belongs to a comment, pass the id of the main post
What it means
Posts are stored as a tree where comments are child posts with parentPostId set. The update endpoint only accepts the root/main post id; passing a comment's id produces this BadRequestException directing you to use the main post's id.
Source
Thrown at libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts:992
// publish date stay as they are, so the running publish workflow is left
// untouched (type "update"). Shared by the agent/MCP tool and the public API
// PUT /posts/:id/settings so both go through one path.
async updatePostSettings(
orgId: string,
postId: string,
settings: Record<string, any>,
creationMethod: CreationMethod
): Promise<{ postId: string; publishDate: string }> {
// Ordered as post -> comments, root includes integration and tags.
const ordered = await this.getPostsRecursively(postId, true, orgId, true);
const [root] = ordered;
if (!root) {
throw new NotFoundException('Post not found');
}
if (root.parentPostId) {
throw new BadRequestException(
'This id belongs to a comment, pass the id of the main post'
);
}
if (root.state !== 'QUEUE' && root.state !== 'DRAFT') {
throw new BadRequestException(
'Only scheduled posts that were not published yet (or drafts) can be updated'
);
}
if (
root.state === 'QUEUE' &&
dayjs.utc(root.publishDate).isBefore(dayjs.utc())
) {
throw new BadRequestException(
'The publish time of this post already passed, it cannot be updated'
);
}View on GitHub (pinned to 0f1647f749)
Solutions
- Resolve the root: follow parentPostId up (or use the API's root post field) and pass that id
- Filter comment nodes out of edit affordances in the UI (check parentPostId before enabling edit)
- If you intended to manage the comment, use the comment-specific endpoints instead of post update
Example fix
// before await updatePost(orgId, comment.id); // after const rootId = comment.parentPostId ?? comment.id; await updatePost(orgId, rootId);
Defensive patterns
Strategy: type-guard
Validate before calling
const rootId = node.parentPostId ?? node.id; if (!node.parentPostId) await updatePost(orgId, node.id, body);
Type guard
const isMainPost = (p: { parentPostId?: string | null }): boolean => !p.parentPostId; Prevention
- Tag comment nodes distinctly in UI collections
- Check parentPostId before enabling edit actions
When it happens
Trigger: Calling updatePost with the id of a comment (a post row whose parentPostId is set), commonly from a UI where comment nodes share the same id-based interactions as posts.
Common situations: Clicking edit on a comment in a thread view that reuses the post-edit modal; deep links built from comment ids; clients that list comments and posts in one collection and lose the distinction.
Related errors
- Post validation failed
- All posts must have an integration id
- Integration with id ${post.integration.id} not found
- This post was already published on ${dayjs .utc(post.publi
- ${validation.name}: Your post should have at least one chara
AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27).
Data as JSON: /api/errors/64380049533f64d5.
Report an issue: GitHub.