{"record":{"id":"64380049533f64d5","repo":"gitroomhq/postiz-app","slug":"this-id-belongs-to-a-comment-pass-the-id-of-the-m","errorCode":null,"errorMessage":"This id belongs to a comment, pass the id of the main post","messagePattern":"This id belongs to a comment, pass the id of the main post","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts","lineNumber":992,"sourceCode":"  // publish date stay as they are, so the running publish workflow is left\n  // untouched (type \"update\"). Shared by the agent/MCP tool and the public API\n  // PUT /posts/:id/settings so both go through one path.\n  async updatePostSettings(\n    orgId: string,\n    postId: string,\n    settings: Record<string, any>,\n    creationMethod: CreationMethod\n  ): Promise<{ postId: string; publishDate: string }> {\n    // Ordered as post -> comments, root includes integration and tags.\n    const ordered = await this.getPostsRecursively(postId, true, orgId, true);\n\n    const [root] = ordered;\n    if (!root) {\n      throw new NotFoundException('Post not found');\n    }\n\n    if (root.parentPostId) {\n      throw new BadRequestException(\n        'This id belongs to a comment, pass the id of the main post'\n      );\n    }\n\n    if (root.state !== 'QUEUE' && root.state !== 'DRAFT') {\n      throw new BadRequestException(\n        'Only scheduled posts that were not published yet (or drafts) can be updated'\n      );\n    }\n\n    if (\n      root.state === 'QUEUE' &&\n      dayjs.utc(root.publishDate).isBefore(dayjs.utc())\n    ) {\n      throw new BadRequestException(\n        'The publish time of this post already passed, it cannot be updated'\n      );\n    }","sourceCodeStart":974,"sourceCodeEnd":1010,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts#L974-L1010","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nawait updatePost(orgId, comment.id);\n// after\nconst rootId = comment.parentPostId ?? comment.id;\nawait updatePost(orgId, rootId);","handlingStrategy":"type-guard","validationCode":"const rootId = node.parentPostId ?? node.id;\nif (!node.parentPostId) await updatePost(orgId, node.id, body);","typeGuard":"const isMainPost = (p: { parentPostId?: string | null }): boolean => !p.parentPostId;","tryCatchPattern":null,"preventionTips":["Tag comment nodes distinctly in UI collections","Check parentPostId before enabling edit actions"],"tags":["posts","comments","validation","tree-structure"],"backgroundTag":"wrong-entity-type-passed","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}