nextcloud/server · warning · Sabre\DAV\Exception\BadRequest

Message exceeds allowed character limit of 1000

Error message

Message exceeds allowed character limit of 1000

What it means

Sabre\DAV\Exception\BadRequest thrown by CommentNode::updateComment() (apps/dav/lib/Comments/CommentNode.php:160) after IComment::setMessage() raised MessageTooLongException. Comments are hard-capped at IComment::MAX_MESSAGE_LENGTH = 1000 characters, and PROPPATCH payloads beyond that are rejected.

Source

Thrown at apps/dav/lib/Comments/CommentNode.php:160

	/**
	 * update the comment's message
	 *
	 * @param $propertyValue
	 * @return bool
	 * @throws BadRequest
	 * @throws \Exception
	 */
	public function updateComment($propertyValue) {
		$this->checkWriteAccessOnComment();
		try {
			$this->comment->setMessage($propertyValue);
			$this->commentsManager->save($this->comment);
			return true;
		} catch (\Exception $e) {
			$this->logger->error($e->getMessage(), ['app' => 'dav/comments', 'exception' => $e]);
			if ($e instanceof MessageTooLongException) {
				$msg = 'Message exceeds allowed character limit of ';
				throw new BadRequest($msg . IComment::MAX_MESSAGE_LENGTH, 0, $e);
			}
			throw $e;
		}
	}

	/**
	 * Updates properties on this node.
	 *
	 * This method received a PropPatch object, which contains all the
	 * information about the update.
	 *
	 * To update specific properties, call the 'handle' method on this object.
	 * Read the PropPatch documentation for more information.
	 *
	 * @param PropPatch $propPatch
	 * @return void
	 */
	#[\Override]

View on GitHub (pinned to ecdeb153ff)

Solutions

  1. Truncate or split the message client-side to <= 1000 chars before PROPPATCH
  2. Use announcements/activities or a real discussion app for longer content
  3. Catch BadRequest with the 'Message exceeds allowed character limit' prefix and surface a validation message

Example fix

// before
$comment->setMessage($userText); // throws when > 1000 chars
// after
$chunks = mb_str_split($userText, 1000);
$comment->setMessage(array_shift($chunks)); // then post the rest as follow-up comments
Defensive patterns

Strategy: validation

Validate before calling

const MAX_MESSAGE_LENGTH = 1000; // IComment::MAX_MESSAGE_LENGTH
if (message.length > MAX_MESSAGE_LENGTH) {
    message = message.slice(0, MAX_MESSAGE_LENGTH); // or split into parts
}

Type guard

const fitsCommentLimit = (msg: string): boolean =>
    [...msg].length <= 1000;

Try / catch

try {
    await client.proppatch(commentUri, { message });
} catch (e) {
    if (e.status === 400 && /character limit of 1000/.test(e.message)) {
        // split text into multiple comments, then retry with first chunk
    }
}

Prevention

When it happens

Trigger: PROPPATCH on /remote.php/dav/comments/<objectType>/<objectId>/<commentId> setting {http://owncloud.org/ns}message (or the message property used by the client) to a string longer than 1000 characters (length as counted by mb_ aware setMessage).

Common situations: Pasting long text into file comments; migration scripts converting threaded discussions into comments; clients not enforcing a local limit.

Related errors


AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17). Data as JSON: /api/errors/82b45b135bd70d58. Report an issue: GitHub.