instructure/canvas-lms · error · RuntimeError

assessor and assessee required

Error message

assessor and assessee required

What it means

RubricAssociation#user_can_assess_for? decides whether a user may submit a rubric assessment for another user. Both assessor and assessee are required keyword args because the permission logic compares them against assessment requests and manage_grades rights. Canvas raises this RuntimeError when either is nil.

Solutions

  1. Resolve both users before the check: pass assessor: current_user, assessee: submission.user
  2. Skip the permission check (or return false) when either user is missing
  3. Guard call sites: only invoke when assessor&.id && assessee&.id

Example fix

// before
assoc.user_can_assess_for?(assessor: teacher, assessee: submission&.user)
// after
if teacher && submission.user
  assoc.user_can_assess_for?(assessor: teacher, assessee: submission.user)
else
  false
end
Defensive patterns

Strategy: validation

Validate before calling

return false if assessor.nil? || assessee.nil?

Type guard

def assessable_users?(a, s) = a.is_a?(User) && s.is_a?(User)

Try / catch

begin
  can = assoc.user_can_assess_for?(assessor:, assessee:)
rescue RuntimeError => e
  raise unless e.message.include?("assessor and assessee")
  can = false
end

Prevention

When it happens

Trigger: Calling user_can_assess_for? with assessor: nil or assessee: nil, typically when the current user or the assessed student cannot be resolved (deleted user, unsaved submission, missing association).

Common situations: Controllers computing rubric permissions for peer reviews where the assessee submission has no user; rubric assessment code paths invoked for anonymous/group submissions; scripts iterating assessments with missing assessor records.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at app/models/rubric_association.rb:197

  def context_name
    @cached_context_name ||= shard.activate do
      Rails.cache.fetch(["short_name_lookup", context_code].cache_key) do
        context.short_name
      end
    end
  end

  def update_values
    self.bookmarked = true if purpose == "bookmark" || bookmarked.nil?
    self.context_code ||= context_type && "#{context_type.underscore}_#{context_id}"
    self.title ||= association_object.try(:title) || association_object.try(:name)
    self.workflow_state ||= "active"
  end
  protected :update_values

  def user_can_assess_for?(assessor: nil, assessee: nil, assessment_type: nil)
    raise "assessor and assessee required" unless assessor && assessee

    context.grants_right?(assessor, :manage_grades) ||
      assessment_requests.incomplete.for_assessee(assessee).pluck(:assessor_id).include?(assessor.id) ||
      user_can_self_assess_for?(assessor:, assessee:, assessment_type:)
  end

  def user_can_self_assess_for?(assessor: nil, assessee: nil, assessment_type: nil)
    assessment_type == "self_assessment" &&
      assignment&.rubric_self_assessment_enabled? &&
      assessor == assessee &&
      rubric_assessments.where(assessment_type: "self_assessment", user_id: assessor).empty?
  end

  def user_did_assess_for?(assessor: nil, assessee: nil)
    raise "assessor and assessee required" unless assessor && assessee

    assessment_requests.complete.for_assessee(assessee).for_assessor(assessor).any?
  end

View on GitHub (pinned to 1c9f0bb801)