{"record":{"id":"566a4c32ef99d2b2","repo":"instructure/canvas-lms","slug":"anonymous-assignments-cannot-be-posted-by-section-566a4c","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_for_sections.rb","lineNumber":46,"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 = course.course_sections.where(id: input[:section_ids])\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 by section before grades are published\"\n    end\n    raise GraphQL::ExecutionError, \"Anonymous assignments cannot be posted by section\" if assignment.anonymous_grading?\n\n    if sections.empty? || sections.count != input[:section_ids].size\n      raise GraphQL::ExecutionError, \"Invalid section ids\"\n    end\n\n    visible_enrollments = course.apply_enrollment_visibility(course.student_enrollments, current_user, sections)\n\n    submissions_scope = input[:graded_only] ? assignment.submissions.postable : assignment.submissions\n    submissions_scope = submissions_scope.joins(user: :enrollments).merge(visible_enrollments)\n    progress = course.progresses.new(tag: \"post_assignment_grades_for_sections\")\n\n    posting_params = {\n      graded_only: !!input[:graded_only],\n      section_names: sections&.pluck(:name)\n    }\n\n    if progress.save\n      progress.process_job(","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/post_assignment_grades_for_sections.rb#L28-L64","documentation":"PostAssignmentGradesForSections always forbids anonymous grading assignments: per-section posting would leak which students are in which section relative to grades, breaking anonymity, so any anonymous_grading? assignment raises this unconditionally.","triggerScenarios":"Any call to postAssignmentGradesForSections where the target assignment has anonymous_grading? true — regardless of which sections are passed.","commonSituations":"Automated per-section posting jobs encountering an anonymously graded assignment in the batch.","solutions":["Skip anonymous assignments in batch posting logic, or use the non-section postAssignmentGrades mutation for all students.","Filter assignments by !anonymous_grading? before scheduling section posts.","Surfacing a clear UI message that anonymous assignments cannot be posted by section."],"exampleFix":"// before\nsections.forEach(s => postAssignmentGradesForSections({assignmentId, sectionIds: [s.id]}));\n// after\nif (assignment.anonymousGrading) {\n  await postAssignmentGrades({assignmentId}); // post all at once\n} else {\n  sections.forEach(s => postAssignmentGradesForSections({assignmentId, sectionIds: [s.id]}));\n}","handlingStrategy":"validation","validationCode":"if (assignment.anonymousGrading) throw new Error('Use postAssignmentGrades (whole course) for anonymous assignments');","typeGuard":"const canPostBySection = (a) => !a.anonymousGrading;","tryCatchPattern":"try { await postSections(); } catch (e) { if (/Anonymous assignments cannot be posted by section/.test(e.message)) fallbackToWholeCoursePost(); }","preventionTips":["Filter anonymous assignments out of section-based batch jobs.","Fall back to whole-course posting for anonymous grading.","Show section-post controls only for non-anonymous assignments."],"tags":["graphql","anonymous-grading","sections"],"backgroundTag":"unsupported-operation","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"}