{"record":{"id":"394b2d54d13d033c","repo":"instructure/canvas-lms","slug":"only-one-assessor-is-allowed-when-rule-applies-to-assessor","errorCode":null,"errorMessage":"Only one assessor is allowed when rule applies to assessor","messagePattern":"Only one assessor is allowed when rule applies to assessor","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/allocation_rule_base.rb","lineNumber":93,"sourceCode":"      end\n    end\n\n    def validate_id_arrays!(input)\n      assessor_ids = input[:assessor_ids]\n      assessee_ids = input[:assessee_ids]\n      applies_to_assessor = input[:applies_to_assessor]\n      reciprocal = input[:reciprocal]\n\n      if reciprocal\n        if assessor_ids.length > 1\n          raise GraphQL::ExecutionError, I18n.t(\"Only one assessor is allowed when creating reciprocal rules\")\n        end\n        if assessee_ids.length > 1\n          raise GraphQL::ExecutionError, I18n.t(\"Only one assessee is allowed when creating reciprocal rules\")\n        end\n      elsif applies_to_assessor\n        if assessor_ids.length > 1\n          raise GraphQL::ExecutionError, I18n.t(\"Only one assessor is allowed when rule applies to assessor\")\n        end\n      elsif assessee_ids.length > 1\n        raise GraphQL::ExecutionError, I18n.t(\"Only one assessee is allowed when rule applies to assessee\")\n      end\n\n      if assessor_ids.empty?\n        raise GraphQL::ExecutionError, I18n.t(\"At least one assessor is required\")\n      end\n      if assessee_ids.empty?\n        raise GraphQL::ExecutionError, I18n.t(\"At least one assessee is required\")\n      end\n\n      if assessor_ids.length > 50\n        raise GraphQL::ExecutionError, I18n.t(\"A maximum of 50 assessors can be provided at once\")\n      end\n      if assessee_ids.length > 50\n        raise GraphQL::ExecutionError, I18n.t(\"A maximum of 50 assessees can be provided at once\")\n      end","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/allocation_rule_base.rb#L75-L111","documentation":"Raised by validate_id_arrays! in AllocationRuleBase when applies_to_assessor is true (and the rule is not reciprocal) but assessor_ids contains more than one ID. In this mode the rule applies to a specific single assessor, so multiple assessors are rejected with a GraphQL ExecutionError.","triggerScenarios":"Calling an allocation-rule create mutation with { appliesToAssessor: true, assessorIds: [id1, id2], ... } — non-reciprocal branch, applies_to_assessor true, assessor_ids.length > 1.","commonSituations":"Reusing a bulk-assignment payload while switching the rule mode to applies-to-assessor; a form retains multiple selected assessors after the user toggles the rule type; copy-pasting between mutation variants without trimming the ID arrays.","solutions":["Send exactly one assessor ID when appliesToAssessor: true.","Remove appliesToAssessor if a multi-assessor rule is intended.","Clear/limit the assessor selection in the UI when this rule mode is chosen.","Client-side validate assessorIds.length === 1 before sending."],"exampleFix":"// before\n{ appliesToAssessor: true, assessorIds: [\"11\", \"12\"], assesseeIds: [\"21\"] }\n// after\n{ appliesToAssessor: true, assessorIds: [\"11\"], assesseeIds: [\"21\"] }","handlingStrategy":"validation","validationCode":"if (input.appliesToAssessor && input.assessorIds.length > 1) {\n  throw new Error('appliesToAssessor rules require exactly one assessor');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await createAllocationRules(input);\n} catch (e) {\n  if (e.message.includes('Only one assessor is allowed when rule applies to assessor')) {\n    // clear extra assessors or drop appliesToAssessor and retry\n  }\n}","preventionTips":["Reset the assessor multi-select when the rule mode changes","Validate arrays against the selected mode before submit","Keep one input-builder function per rule mode","Show array length next to the submit button during development"],"tags":["graphql","validation","canvas"],"backgroundTag":"invalid-argument-value","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"}