{"record":{"id":"86d5498fb8a3a751","repo":"instructure/canvas-lms","slug":"assessment-type-required-for-assessing","errorCode":null,"errorMessage":"Assessment type required for assessing","messagePattern":"Assessment type required for assessing","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"app/models/rubric_association.rb","lineNumber":311,"sourceCode":"  def assessment_points(criterion, data)\n    if criterion.learning_outcome_id && !context.feature_enabled?(:outcome_extra_credit)\n      [criterion.points, data[:points].to_f].min\n    else\n      data[:points].to_f\n    end\n  end\n  protected :assessment_points\n\n  def assess(opts = {})\n    # TODO: what if this is for a group assignment?  Seems like it should\n    # give all students for the group assignment the same rubric assessment\n    # results.\n    association = self\n    params = opts[:assessment]\n    raise \"User required for assessing\" unless opts[:user]\n    raise \"Assessor required for assessing\" unless opts[:assessor]\n    raise \"Artifact required for assessing\" unless opts[:artifact]\n    raise \"Assessment type required for assessing\" unless params[:assessment_type]\n\n    if opts[:artifact].is_a?(Quizzes::QuizSubmission)\n      opts[:artifact] = association_object.find_or_create_submission(opts[:artifact].user)\n    end\n\n    if association_object.is_a?(Assignment) && !association_object.grade_group_students_individually\n      group, students_to_assess = association_object.group_students(opts[:artifact].student)\n      if group\n        provisional_grader = opts[:artifact].is_a?(ModeratedGrading::ProvisionalGrade) && opts[:assessor]\n        artifacts_to_assess = students_to_assess.map do |student|\n          association_object.find_asset_for_assessment(self, student, provisional_grader:).first\n        end\n      else\n        artifacts_to_assess = [opts[:artifact]]\n      end\n    else\n      artifacts_to_assess = [opts[:artifact]]\n    end","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/models/rubric_association.rb#L293-L329","documentation":"RubricAssociation#assess requires params[:assessment_type] (the assessment hash inside opts). This guard fires when the assessment type — e.g. 'grading', 'peer_review', or 'summary' — is missing, so Canvas cannot determine what kind of rubric assessment to record. It is a fail-fast contract check before assessment processing begins.","triggerScenarios":"Calling rubric_association.assess(user:, assessor:, artifact:) with an :assessment hash lacking the :assessment_type key; API/controller callers forwarding only score/criterion params without assessment_type; assessment params built dynamically and the type key dropped.","commonSituations":"Custom grading tools that copy example payloads missing assessment_type; version changes/integrations using old param names; peer-review automation scripts that set other assessment fields but forget the type.","solutions":["Include assessment_type in the assessment hash: assessment: {assessment_type: 'grading', ...criterion scores}","Use a supported type: 'grading', 'peer_review', or 'summary' — an unsupported value will fail downstream","Validate params before calling: raise 'assessment_type missing' unless params[:assessment_type]"],"exampleFix":"// before\nrubric_association.assess(\n  user: student, assessor: assessor, artifact: submission,\n  assessment: { score: 8 }\n)\n// after\nrubric_association.assess(\n  user: student, assessor: assessor, artifact: submission,\n  assessment: { assessment_type: 'grading', score: 8 }\n)","handlingStrategy":"validation","validationCode":"raise 'assessment_type missing' unless params[:assessment_type].in?(%w[grading peer_review summary])","typeGuard":"valid = %w[grading peer_review summary].include?(params[:assessment_type])\n","tryCatchPattern":"begin\n  rubric_association.assess(opts)\nrescue RuntimeError => e\n  handle_missing_type if e.message == 'Assessment type required for assessing'\nend","preventionTips":["Always set assessment_type: 'grading' (or peer_review/summary) in the assessment hash","Centralize assessment param construction","Validate params at the API boundary"],"tags":["rubric","missing-argument","ruby"],"backgroundTag":"missing-required-argument","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"}