{"record":{"id":"82b45b135bd70d58","repo":"nextcloud/server","slug":"message-exceeds-allowed-character-limit-of-1000","errorCode":null,"errorMessage":"Message exceeds allowed character limit of 1000","messagePattern":"Message exceeds allowed character limit of 1000","errorType":"http","errorClass":"Sabre\\DAV\\Exception\\BadRequest","httpStatus":400,"severity":"warning","filePath":"apps/dav/lib/Comments/CommentNode.php","lineNumber":160,"sourceCode":"\t/**\n\t * update the comment's message\n\t *\n\t * @param $propertyValue\n\t * @return bool\n\t * @throws BadRequest\n\t * @throws \\Exception\n\t */\n\tpublic function updateComment($propertyValue) {\n\t\t$this->checkWriteAccessOnComment();\n\t\ttry {\n\t\t\t$this->comment->setMessage($propertyValue);\n\t\t\t$this->commentsManager->save($this->comment);\n\t\t\treturn true;\n\t\t} catch (\\Exception $e) {\n\t\t\t$this->logger->error($e->getMessage(), ['app' => 'dav/comments', 'exception' => $e]);\n\t\t\tif ($e instanceof MessageTooLongException) {\n\t\t\t\t$msg = 'Message exceeds allowed character limit of ';\n\t\t\t\tthrow new BadRequest($msg . IComment::MAX_MESSAGE_LENGTH, 0, $e);\n\t\t\t}\n\t\t\tthrow $e;\n\t\t}\n\t}\n\n\t/**\n\t * Updates properties on this node.\n\t *\n\t * This method received a PropPatch object, which contains all the\n\t * information about the update.\n\t *\n\t * To update specific properties, call the 'handle' method on this object.\n\t * Read the PropPatch documentation for more information.\n\t *\n\t * @param PropPatch $propPatch\n\t * @return void\n\t */\n\t#[\\Override]","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/Comments/CommentNode.php#L142-L178","documentation":"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.","triggerScenarios":"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).","commonSituations":"Pasting long text into file comments; migration scripts converting threaded discussions into comments; clients not enforcing a local limit.","solutions":["Truncate or split the message client-side to <= 1000 chars before PROPPATCH","Use announcements/activities or a real discussion app for longer content","Catch BadRequest with the 'Message exceeds allowed character limit' prefix and surface a validation message"],"exampleFix":"// before\n$comment->setMessage($userText); // throws when > 1000 chars\n// after\n$chunks = mb_str_split($userText, 1000);\n$comment->setMessage(array_shift($chunks)); // then post the rest as follow-up comments","handlingStrategy":"validation","validationCode":"const MAX_MESSAGE_LENGTH = 1000; // IComment::MAX_MESSAGE_LENGTH\nif (message.length > MAX_MESSAGE_LENGTH) {\n    message = message.slice(0, MAX_MESSAGE_LENGTH); // or split into parts\n}","typeGuard":"const fitsCommentLimit = (msg: string): boolean =>\n    [...msg].length <= 1000;","tryCatchPattern":"try {\n    await client.proppatch(commentUri, { message });\n} catch (e) {\n    if (e.status === 400 && /character limit of 1000/.test(e.message)) {\n        // split text into multiple comments, then retry with first chunk\n    }\n}","preventionTips":["Enforce a 1000-character counter in comment input UIs","Split long content into follow-up comments","Check IComment::MAX_MESSAGE_LENGTH when upgrading integrations"],"tags":["dav","comments","proppatch","bad-request","http-400","length-limit","validation"],"backgroundTag":"input-length-limit-exceeded","analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}