{"record":{"id":"53cf62319837528a","repo":"instructure/canvas-lms","slug":"unable-to-create-group-set","errorCode":null,"errorMessage":"Unable to create group set","messagePattern":"Unable to create group set","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/create_group_set.rb","lineNumber":68,"sourceCode":"        assign_async: input[:assign_async],\n        assign_unassigned_members: input[:assign_unassigned_members],\n      }\n\n      populate_group_category(options)\n    else\n      raise GraphQL::ExecutionError, \"Insufficient permissions to create group set\"\n    end\n\n    { group_set: @group_category }\n  end\n\n  # Private\n  def populate_group_category(options)\n    @group_category = GroupCategories::ParamsPolicy.new(@group_category, @context).populate_with(options)\n\n    SubmissionLifecycleManager.with_executing_user(@current_user) do\n      unless @group_category.save\n        raise GraphQL::ExecutionError, \"Unable to create group set\"\n      end\n    end\n  end\n\n  def get_group_count(count)\n    if count && count > 0\n      [count, Setting.get(\"max_groups_in_new_category\", \"200\").to_i].min\n    else\n      nil\n    end\n  end\n\n  # The purpose of this method is to generate a list of valid contexts for the group set\n  # based on the values in Types::GroupSetContextType\n  # The context_fetcher requires a list of contexts that are capitalized on the first letter\n  def valid_contexts\n    Types::GroupSetContextType.values.values.map(&:value)\n  end","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/create_group_set.rb#L50-L86","documentation":"In populate_group_category, the newly built GroupCategory fails to save (validations or callbacks reject it), and the mutation raises this GraphQL::ExecutionError. GroupCategories::ParamsPolicy populates the attributes from the input options, then SubmissionLifecycleManager wraps the save; a false return from save means invalid model state, not a permission problem.","triggerScenarios":"createGroupSet with an invalid name (blank, too long, duplicate in context), invalid self_signup/auto_leader_type/group_limit combinations, create_group_member_count or group_limit outside allowed bounds — anything making @group_category.save return false inside SubmissionLifecycleManager.with_executing_user.","commonSituations":"Passing self_signup without enable_self_signup consistency, group_limit over the account max, a name colliding with an existing group set in the same course, auto_leader_type set without enable_auto_leader, create_group_count above the 200 cap being silently clamped but member counts conflicting.","solutions":["Inspect @group_category.errors after the failed save (rails console or the mutation's GraphQL errors) to see which validation failed.","Ensure name is present and unique within the course/group context.","Validate the combination of self_signup, restrict_self_signup, enable_auto_leader, auto_leader_type — incompatible option pairs commonly fail ParamsPolicy population.","Check group_limit / create_group_member_count are positive integers within account limits.","Test the same inputs via console: GroupCategories::ParamsPolicy.new(cat, ctx).populate_with(options) then save, to reproduce and see errors."],"exampleFix":"// before (invalid combo fails save)\ncreateGroupSet(input: {name: \"Groups\", selfSignup: \"restricted\"})\n// after (self-signup flags consistent)\ncreateGroupSet(input: {name: \"Groups\", enableSelfSignup: true, restrictSelfSignup: true, selfSignup: \"restricted\"})","handlingStrategy":"validation","validationCode":"# validate inputs before the mutation\ncourse.group_categories.new(name: name).valid? or\noptions = { name:, self_signup:, auto_leader_type:, group_limit: }\nprobe = course.group_categories.build\nGroupCategories::ParamsPolicy.new(probe, course).populate_with(options)\nraise probe.errors.full_messages.join(', ') unless probe.valid?","typeGuard":"def valid_group_set_options?(options, context)\n  cat = context.group_categories.build\n  GroupCategories::ParamsPolicy.new(cat, context).populate_with(options)\n  cat.valid?\nend","tryCatchPattern":"rescue GraphQL::ExecutionError => e\n  if e.message == 'Unable to create group set'\n    Rails.logger.warn(\"group set save failed: #{cat&.errors&.full_messages}\")\n  end\nend","preventionTips":["Keep group set names unique within a course","Only send compatible flag combinations (self_signup with enable_self_signup, auto_leader_type with enable_auto_leader)","Respect group_limit / member-count account limits","Dry-run the ParamsPolicy population in a spec before shipping new callers"],"tags":["graphql","validation","ruby","activerecord"],"backgroundTag":"schema-validation-failed","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"}