instructure/canvas-lms · error · GraphQL::ExecutionError

At least one assessor is required

Error message

At least one assessor is required

What it means

Raised by validate_id_arrays! in AllocationRuleBase when the assessor_ids array is empty. Every allocation rule requires at least one assessor, so an empty list is rejected with a GraphQL ExecutionError before any rule is created.

Solutions

  1. Provide at least one assessor ID in the mutation input.
  2. Disable submit when no assessor is selected and/or show the error client-side.
  3. Check the query that generates assessor IDs for empty results before calling the mutation.
  4. Confirm the IDs are valid active users eligible as assessors in the course.

Example fix

// before
{ assessorIds: [], assesseeIds: ["21"] }
// after
{ assessorIds: ["11"], assesseeIds: ["21"] }
Defensive patterns

Strategy: validation

Validate before calling

if (!Array.isArray(input.assessorIds) || input.assessorIds.length === 0) {
  throw new Error('Select at least one assessor before submitting');
}

Type guard

function hasAssessors(input) {
  return Array.isArray(input.assessorIds) && input.assessorIds.length > 0;
}

Try / catch

try {
  await createAllocationRules(input);
} catch (e) {
  if (e.message.includes('At least one assessor is required')) {
    // prompt user to pick assessors
  }
}

Prevention

When it happens

Trigger: Calling an allocation-rule create mutation with assessorIds: [] (or omitted/null resolving to []) after the cardinality checks pass.

Common situations: A UI filter matches no eligible assessors (e.g. all students already assigned) and the empty selection is still submitted; a script builds the ID array from an upstream query that returned nothing; a form reset clears selections but submit stays enabled.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/d3f648fcbf2c6e20. Report an issue: GitHub.

Appendix: source

Thrown at app/graphql/mutations/allocation_rule_base.rb:100

      reciprocal = input[:reciprocal]

      if reciprocal
        if assessor_ids.length > 1
          raise GraphQL::ExecutionError, I18n.t("Only one assessor is allowed when creating reciprocal rules")
        end
        if assessee_ids.length > 1
          raise GraphQL::ExecutionError, I18n.t("Only one assessee is allowed when creating reciprocal rules")
        end
      elsif applies_to_assessor
        if assessor_ids.length > 1
          raise GraphQL::ExecutionError, I18n.t("Only one assessor is allowed when rule applies to assessor")
        end
      elsif assessee_ids.length > 1
        raise GraphQL::ExecutionError, I18n.t("Only one assessee is allowed when rule applies to assessee")
      end

      if assessor_ids.empty?
        raise GraphQL::ExecutionError, I18n.t("At least one assessor is required")
      end
      if assessee_ids.empty?
        raise GraphQL::ExecutionError, I18n.t("At least one assessee is required")
      end

      if assessor_ids.length > 50
        raise GraphQL::ExecutionError, I18n.t("A maximum of 50 assessors can be provided at once")
      end
      if assessee_ids.length > 50
        raise GraphQL::ExecutionError, I18n.t("A maximum of 50 assessees can be provided at once")
      end
    end

    def get_assignment(assignment_id)
      Assignment.active.find(assignment_id)
    rescue ActiveRecord::RecordNotFound
      raise GraphQL::ExecutionError, I18n.t("Assignment not found")
    end

View on GitHub (pinned to 1c9f0bb801)