passbolt/passbolt_api · critical · InternalErrorException

Could not save the comment, please try again later.

Error message

Could not save the comment, please try again later.

What it means

CommentsAddService::add() throws this 500 when the Comments table save() returns false even after entity validation passed. It re-runs _handleValidationErrors first; reaching this error means save failed for a non-validation reason (persistence-layer problem), so the server reports a generic internal error and suggests retrying.

Solutions

  1. Retry the request after a short delay — the message explicitly suggests a transient problem.
  2. Check the database server health (connection, disk space, locks) and the passbolt error logs for the underlying DB exception.
  3. Ensure no custom plugin listener on Model.beforeSave/afterSave is aborting comment saves.
Defensive patterns

Strategy: retry

Validate before calling

// Nothing caller-side prevents a server-side save failure; just confirm entity fields are valid first:
if (!commentText?.trim()) throw new Error('content required');

Try / catch

try { await addComment(id, data); }
catch (e) {
  if (e.response?.status === 500 && /Could not save the comment/.test(e.response?.data?.message ?? '')) {
    await delay(1000); return addComment(id, data); // one retry
  }
  throw e;
}

Prevention

When it happens

Trigger: Database connection failure, DB write error, transaction/lock issues, or a behavior/event listener aborting the save — occurring during POST of a comment whose entity validated fine.

Common situations: Database temporarily down or out of connections; disk full on the DB host; deadlock under concurrent writes; custom plugin event handlers throwing/altering the save result.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/eb111d31c7fcfc14. Report an issue: GitHub.

Appendix: source

Thrown at src/Service/Comments/CommentsAddService.php:73

     * @param \App\Utility\UserAccessControl $uac The user access control
     * @param string $foreignKey The identifier of the resource to add a comment to
     * @param array $data The comment data
     * @return \App\Model\Entity\Comment $comment comment entity
     * @throws \Cake\Http\Exception\InternalErrorException if the comment couldn't be saved
     */
    public function add(UserAccessControl $uac, string $foreignKey, array $data): Comment
    {
        if (!Validation::uuid($foreignKey)) {
            throw new BadRequestException(__('The resource identifier should be a valid UUID.'));
        }

        $comment = $this->_buildAndValidateCommentEntity($uac, $foreignKey, $data);
        $this->_handleValidationErrors($comment);

        if (!$this->Comments->save($comment)) {
            $this->_handleValidationErrors($comment);
            $oops = __('Could not save the comment, please try again later.');
            throw new InternalErrorException($oops);
        }
        $this->_notifyUsers($comment);

        return $comment;
    }

    /**
     * Manage validation errors.
     *
     * @param \App\Model\Entity\Comment $comment comment
     * @throws \Cake\Http\Exception\BadRequestException
     * @throws \Cake\Http\Exception\NotFoundException
     * @return void
     */
    protected function _handleValidationErrors(Comment $comment): void
    {
        $errors = $comment->getErrors();
        if (!empty($errors)) {

View on GitHub (pinned to 31c1bbc10f)