{"record":{"id":"c05b832577bceef5","repo":"instructure/canvas-lms","slug":"the-file-is-empty-or-does-not-contain-valid-assessment-data","errorCode":null,"errorMessage":"The file is empty or does not contain valid assessment data.","messagePattern":"The file is empty or does not contain valid assessment data\\.","errorType":"validation","errorClass":"DataFormatError","httpStatus":null,"severity":"error","filePath":"app/models/rubric_assessment_import.rb","lineNumber":117,"sourceCode":"    rescue => e\n      ErrorReport.log_exception(\"rubric_assessments_import\", e)\n      update!(error_count: 1, error_data: [{ message: I18n.t(\"An error occurred while importing rubrics.\"), exception: e.message }])\n      track_error\n      job_failed!\n    end\n  end\n\n  def track_error\n    InstStatsd::Statsd.distributed_increment(\"#{assignment.class.to_s.downcase}.rubrics.csv_imported_with_error\")\n  end\n\n  def process_assessments\n    error_data = []\n\n    rubric_association = assignment.rubric_association\n    rubric = rubric_association.rubric\n    assessments_by_student = RubricAssessmentCSVImporter.new(attachment, rubric, rubric_association).parse\n    raise DataFormatError, I18n.t(\"The file is empty or does not contain valid assessment data.\") if assessments_by_student.empty?\n\n    total_assessments = assessments_by_student.keys.count\n\n    students = User.where(id: assessments_by_student.keys).index_by(&:id)\n    student_submissions = assignment.submissions.where(user_id: students.keys).index_by(&:user_id)\n\n    assessments_by_student.each_with_index do |(student_id, assessment), student_index|\n      student_to_assess = students[student_id.to_i]\n\n      raise DataFormatError, I18n.t(\"Student with ID %{student_id} not found.\", student_id:) unless student_to_assess\n      raise UnauthorizedError unless rubric_association.user_can_assess_for?(assessor: user, assessee: student_to_assess)\n\n      assessment = assessment.to_h do |criterion|\n        [:\"criterion_#{criterion[:id]}\",\n         {\n           points: criterion[:points],\n           comments: criterion[:comments],\n           description: criterion[:rating]","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/models/rubric_assessment_import.rb#L99-L135","documentation":"RubricAssessmentImport#process_assessments raises DataFormatError when the parsed CSV yields no assessments by student — meaning the uploaded attachment produced zero valid rows (empty file or content the RubricAssessmentCSVImporter could not interpret).","triggerScenarios":"Uploading an empty CSV, a file with only headers, a wrong file type (e.g. xlsx saved with .csv extension but wrong encoding/content), or a CSV whose columns do not match the expected assessment format so the importer returns an empty hash.","commonSituations":"Users exporting from a spreadsheet but exporting the wrong sheet; CSV with wrong delimiter (semicolon vs comma); template columns renamed or reordered; uploading the rubric CSV instead of the assessments CSV.","solutions":["Download the provided assessment CSV template and populate it without changing header names","Ensure the file is a real comma-separated CSV (re-save from the spreadsheet app as 'CSV UTF-8')","Verify the file contains at least one data row with a valid student ID and scores","Check that the student IDs in the file exist in the course (also avoids error 487)"],"exampleFix":"// before\nimport_file(my_export.xlsx)\n// after\ncsv = File.read(\"assessments.csv\") # headers: student_id, criterion_id, points, comments\ncsv += \"12345,Criterion1,10,good work\\n\" if csv.lines.size <= 1","handlingStrategy":"validation","validationCode":"csv = CSV.read(uploaded_path, headers: true)\nraise \"file has no data rows\" if csv.empty?\nraise \"missing required headers\" unless (csv.headers & REQUIRED_HEADERS) == REQUIRED_HEADERS","typeGuard":null,"tryCatchPattern":"begin\n  import.process\nrescue DataFormatError => e\n  flash[:error] = e.message\nend","preventionTips":["Always start from the provided CSV template","Re-export as CSV UTF-8 from the spreadsheet app","Preview the file in a text editor before uploading","Verify the correct export (assessments vs rubrics) is uploaded"],"tags":["csv","import","validation","rubrics"],"backgroundTag":"empty-result-set","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"}