{"record":{"id":"75b27f13a8d2fba1","repo":"instructure/canvas-lms","slug":"too-many-participants-for-group-conversation","errorCode":null,"errorMessage":"Too many participants for group conversation","messagePattern":"Too many participants for group conversation","errorType":"exception","errorClass":"ConversationsHelper::Error","httpStatus":400,"severity":"error","filePath":"app/helpers/conversations_helper.rb","lineNumber":57,"sourceCode":"\n    if context.is_a?(Course) && context.workflow_state == \"completed\" && !context.grants_right?(current_user, session, :read_as_admin)\n      raise ConversationsHelper::Error.new(message: I18n.t(\"Course concluded, unable to send messages\"), status: :unauthorized, attribute: \"workflow_state\")\n    end\n\n    if body.blank?\n      raise ConversationsHelper::Error.new(message: I18n.t(\"Unable to create message without a body\"), status: :bad_request, attribute: \"empty_message\")\n    end\n\n    recipients = normalize_recipients(\n      recipients:,\n      context_code:,\n      conversation_id: conversation.conversation_id,\n      current_user:,\n      session:\n    )\n\n    if recipients && !conversation.conversation.can_add_participants?(recipients)\n      raise ConversationsHelper::Error.new(message: I18n.t(\"Too many participants for group conversation\"), status: :bad_request, attribute: \"recipients\")\n    end\n\n    invalid_recipients = get_invalid_recipients(context, recipients, current_user)\n    unless invalid_recipients.to_a.empty?\n      invalid_recipients = invalid_recipients.pluck(1)\n      raise ConversationsHelper::Error.new(message: I18n.t(\"The following recipients have no active enrollment in the course, %{invalid_recipients}, unable to send messages\", invalid_recipients:), status: :unauthorized, attribute: \"recipients\")\n    end\n\n    tags = infer_tags(\n      recipients: conversation.conversation.participants.pluck(:id),\n      context_code:\n    )\n\n    validate_message_ids(message_ids, conversation, current_user:)\n    message_args = build_message_args(\n      body:,\n      attachment_ids:,\n      domain_root_account_id:,","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/helpers/conversations_helper.rb#L39-L75","documentation":"process_response enforces group conversation size limits: conversation#can_add_participants?(recipients) must be true for the recipients being added. When the addition would exceed the allowed number of participants, ConversationsHelper::Error is raised with status :bad_request and attribute 'recipients'.","triggerScenarios":"Adding a batch of recipients to a group conversation that would push the participant count past the configured maximum (conversation batch size / max participants setting).","commonSituations":"Bulk 'message all students' flows with very large enrollments; an admin lowering the max-participants setting below existing group sizes; copy/pasting a large recipient list into the composer.","solutions":["Split the recipients into smaller batches that stay within the conversation participant limit","Check conversation#can_add_participants?(recipients) before calling and show the user a friendly limit error","Increase the conversation participant limit setting if the policy allows","Trim the recipient list (e.g. use course sections or filters) instead of one giant add"],"exampleFix":"// before\nadd_recipients(conversation, all_student_ids)\n// after\nrecipients.take(max_participants) # or chunk and send separate conversations\nadd_recipients(conversation, recipients) if conversation.can_add_participants?(recipients)","handlingStrategy":"validation","validationCode":"return render json: { error: 'too many recipients' }, status: :bad_request unless conversation.conversation.can_add_participants?(recipients)","typeGuard":null,"tryCatchPattern":"begin\n  process_response(...)\nrescue ConversationsHelper::Error => e\n  render json: { error: e.message }, status: :bad_request if e.message.include?('Too many participants')\nend","preventionTips":["Cap recipient list size in the UI before submit","Check can_add_participants? proactively","Chunk large recipient sets into multiple conversations"],"tags":["conversations","validation","limits"],"backgroundTag":"value-out-of-range","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}