BookStackApp/BookStack · error · Exception
errors.cannot_add_comment_to_draft
Error message
errors.cannot_add_comment_to_draft
What it means
Generic \Exception (with a translated message) thrown in CommentRepo::create when the target entity is a draft Page; BookStack forbids comments on drafts since drafts are not visible to other users. Input at fault: a Page entity with draft=true passed to create().
Source
Thrown at app/Activity/CommentRepo.php:48
}
/**
* Start a query for comments visible to the user.
* @return Builder<Comment>
*/
public function getQueryForVisible(): Builder
{
return Comment::query()->scopes('visible');
}
/**
* Create a new comment on an entity.
*/
public function create(Entity $entity, string $html, ?int $parentId, string $contentRef): Comment
{
// Prevent comments being added to draft pages
if ($entity instanceof Page && $entity->draft) {
throw new \Exception(trans('errors.cannot_add_comment_to_draft'));
}
// Validate parent ID
if ($parentId !== null) {
$parentCommentExists = Comment::query()
->where('commentable_id', '=', $entity->id)
->where('commentable_type', '=', $entity->getMorphClass())
->where('local_id', '=', $parentId)
->exists();
if (!$parentCommentExists) {
$parentId = null;
}
}
$userId = user()->id;
$comment = new Comment();
$comment->html = HtmlDescriptionFilter::filterFromString($html);View on GitHub (pinned to 18f8469a1c)
Solutions
- Publish the draft page before adding comments
- Only surface comment UI for pages that are published
- If hit programmatically, check $page->draft before calling CommentRepo::create
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at app/Activity/CommentRepo.php:48 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BookStackApp/BookStack@18f8469a1c (2026-09-02).
Data as JSON: /api/errors/ad8524c1b4096766.
Report an issue: GitHub.