{"record":{"id":"fafee996d269ba88","repo":"instructure/canvas-lms","slug":"cannot-create-collaborative-groups-in-a-non-collaborative","errorCode":null,"errorMessage":"cannot create collaborative groups in a non-collaborative group set","messagePattern":"cannot create collaborative groups in a non-collaborative group set","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/create_group_in_set.rb","lineNumber":43,"sourceCode":"  argument :name, String, required: true\n  argument :non_collaborative, Boolean, required: false, default_value: false\n\n  field :group, Types::GroupType, null: true\n\n  def resolve(input:)\n    category_id = GraphQLHelpers.parse_relay_or_legacy_id(input[:group_set_id], \"GroupSet\")\n    set = GroupCategory.find(category_id)\n    account = (set.context_type == \"Account\") ? set.context : set.context&.account\n    verify_authorized_action!(set.context, :manage_groups_add)\n\n    if input[:non_collaborative]\n      if account&.allow_assign_to_differentiation_tags?\n        raise GraphQL::ExecutionError, \"insufficient permissions to create non-collaborative groups\" unless set.context&.grants_right?(current_user, session, :manage_tags_add)\n      else\n        raise GraphQL::ExecutionError, \"cannot create non-collaborative groups when the differentiation tags feature flag is disabled\"\n      end\n    elsif set.non_collaborative\n      raise GraphQL::ExecutionError, \"cannot create collaborative groups in a non-collaborative group set\"\n    end\n\n    group = set.groups.build(name: input[:name], context: set.context, non_collaborative: input[:non_collaborative])\n\n    if group.save\n      { group: }\n    else\n      errors_for(group)\n    end\n  rescue ActiveRecord::RecordNotFound\n    raise GraphQL::ExecutionError, \"not found\"\n  end\nend\n","sourceCodeStart":25,"sourceCodeEnd":57,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/create_group_in_set.rb#L25-L57","documentation":"CreateGroupInSet#resolve raises this ExecutionError when the target GroupCategory is itself non_collaborative (a differentiation-tag set) and the caller attempts to create a regular collaborative group inside it. Set type and group type must match: collaborative groups cannot live in non-collaborative sets.","triggerScenarios":"createGroupInSet with non_collaborative: false (or omitted) targeting a group set where set.non_collaborative == true.","commonSituations":"User picks a differentiation-tag set in the group-set dropdown while the form defaults to creating a standard group; bulk-import scripts iterate all sets in a course including tag sets; UI predating differentiation tags not distinguishing set types.","solutions":["Pass non_collaborative: true when the target set is non-collaborative.","Choose a collaborative group set instead if a standard group is intended.","Filter non-collaborative sets out of group-set pickers for standard group creation.","Fetch the group set (groupSet.nonCollaborative via GraphQL) and validate before submitting."],"exampleFix":"// before\ncreateGroupInSet({groupSetId, name})\n\n// after\nconst set = await fetchGroupSet(groupSetId)\ncreateGroupInSet({groupSetId, name, non_collaborative: set.nonCollaborative})","handlingStrategy":"validation","validationCode":"const set = await fetchGroupSet(groupSetId)\nif (!set.nonCollaborative && nonCollaborative) throw new Error('set/group type mismatch')\nif (set.nonCollaborative && !nonCollaborative) throw new Error('collaborative group not allowed in tag set')","typeGuard":"const typeMatches = (set, nonCollaborative) => Boolean(set.nonCollaborative) === Boolean(nonCollaborative)","tryCatchPattern":null,"preventionTips":["Default non_collaborative to match the target set's type.","Filter group-set pickers by set type.","Include nonCollaborative in groupSet GraphQL selections."],"tags":["graphql","groups","validation","differentiation-tags"],"backgroundTag":"invalid-state-transition","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"}