{"record":{"id":"ed5aeb91a9b47716","repo":"instructure/canvas-lms","slug":"anonymous-assignments-cannot-be-posted-by-section-post","errorCode":null,"errorMessage":"Anonymous assignments cannot be posted by section","messagePattern":"Anonymous assignments cannot be posted by section","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/post_assignment_grades.rb","lineNumber":48,"sourceCode":"  field :assignment, Types::AssignmentType, null: true\n  field :progress, Types::ProgressType, null: true\n  field :sections, [Types::SectionType], null: true\n\n  def resolve(input:)\n    begin\n      assignment = AbstractAssignment.find_assignment_or_peer_review(input[:assignment_id])\n      course = assignment.context\n      sections = input[:section_ids] ? course.course_sections.where(id: input[:section_ids]) : nil\n    rescue ActiveRecord::RecordNotFound\n      raise GraphQL::ExecutionError, \"not found\"\n    end\n\n    verify_authorized_action!(assignment, :grade)\n\n    unless assignment.grades_published?\n      raise GraphQL::ExecutionError, \"Assignments under moderation cannot be posted before grades are published\"\n    end\n    raise GraphQL::ExecutionError, \"Anonymous assignments cannot be posted by section\" if sections && assignment.anonymous_grading?\n\n    if input[:graded_only] && assignment.anonymous_grading\n      raise GraphQL::ExecutionError, \"Anonymous assignments cannot be posted by graded only\"\n    end\n\n    if input[:only_student_ids] && input[:skip_student_ids]\n      raise GraphQL::ExecutionError, I18n.t(\"{a} and {b} cannot be used together\", a: \"only_student_ids\", b: \"skip_student_ids\")\n    end\n\n    visible_enrollments = course.apply_enrollment_visibility(course.student_enrollments, current_user, sections)\n    visible_enrollments = visible_enrollments.where(user_id: input[:only_student_ids]) if input[:only_student_ids]\n    visible_enrollments = visible_enrollments.where.not(user_id: input[:skip_student_ids]) if input[:skip_student_ids]\n\n    submissions_scope = input[:graded_only] ? assignment.submissions.postable : assignment.submissions\n    submissions_scope = submissions_scope.joins(user: :enrollments).merge(visible_enrollments)\n    submission_ids = submissions_scope.pluck(:id)\n    progress = course.progresses.new(tag: \"post_assignment_grades\")\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/post_assignment_grades.rb#L30-L66","documentation":"PostAssignmentGrades raises this when section_ids are supplied for an assignment with anonymous_grading enabled. Anonymous assignments must be posted for all students at once so anonymity is not broken by per-section posting.","triggerScenarios":"postAssignmentGrades with both a non-empty section_ids input and an assignment whose anonymous_grading? is true.","commonSituations":"UIs that preserve a previously selected section filter when the teacher later enables anonymous grading; scripts posting by section copied from non-anonymous flows.","solutions":["Remove section_ids from the input and post the anonymous assignment for the whole course.","Disable anonymous grading on the assignment if section-level posting is genuinely required (usually not possible after submissions).","Guard client code: if assignment.anonymousGrading, hide/disable the section picker."],"exampleFix":"// before\npostAssignmentGrades(input: {assignmentId, sectionIds: [\"17\"], ...})\n// after\nconst input = { assignmentId, gradedOnly: true };\nif (!assignment.anonymousGrading) input.sectionIds = sectionIds;\nawait postAssignmentGrades({input});","handlingStrategy":"validation","validationCode":"if (assignment.anonymousGrading && sectionIds?.length) throw new Error('Anonymous assignments cannot be posted by section');","typeGuard":null,"tryCatchPattern":"try { await post(); } catch (e) { if (/cannot be posted by section/.test(e.message)) resetSectionFilter(); }","preventionTips":["Disable the section picker when the assignment is anonymously graded.","Clear saved section filters when assignment settings change.","Validate inputs client-side mirroring server rules."],"tags":["graphql","anonymous-grading","sections"],"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"}