instructure/canvas-lms · error · GraphQL::ExecutionError
Anonymous assignments cannot be posted by section
Error message
Anonymous assignments cannot be posted by section
What it means
When sections are supplied, the mutation refuses to act on anonymously graded assignments (assignment.anonymous_grading? is true), because posting/hiding by section would deanonymize students by revealing which students belong to each section.
Solutions
- Hide/post grades for the whole assignment without section_ids (omit section_ids).
- Turn off anonymous grading if section-level operations are truly required (only possible before submissions, per policy), or re-create the assignment without anonymity.
- Gate the UI: disable section selection when assignment.anonymousGrading is true.
- If only certain students should be affected, use only_student_ids/skip_student_ids instead of sections — anonymity of the mapping is preserved differently, verify policy allows it.
Example fix
// before
await HideAssignmentGrades.mutate({ assignmentId, sectionIds });
// after
if (assignment.anonymousGrading) {
await HideAssignmentGrades.mutate({ assignmentId }); // no sections
} else {
await HideAssignmentGrades.mutate({ assignmentId, sectionIds });
} Defensive patterns
Strategy: validation
Validate before calling
if (assignment.anonymousGrading && sectionIds?.length) {
sectionIds = undefined; // whole-assignment operation instead
} Type guard
const sectionScopingAllowed = (a) => Boolean(a && !a.anonymousGrading && !a.anonymizeStudents);
Try / catch
try { await hideGrades({ assignmentId, sectionIds }); }
catch (e) {
if (String(e).includes('Anonymous assignments')) return hideGrades({ assignmentId });
throw e;
} Prevention
- Disable section filters in UI for anonymous assignments
- Audit scripts for hardcoded section_ids
- Understand Canvas anonymity flags before building grade tooling
- Test grade workflows with an anonymous assignment fixture
When it happens
Trigger: Calling hideAssignmentGrades with a non-empty section_ids on an assignment created with anonymous grading (anonymous_grading enabled and assignment is anonymous).
Common situations: Teachers used to section-level posting trying it on an anonymized assignment; scripts that always pass section_ids copied from non-anonymous flows; UI not hiding section options for anonymous assignments.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Anonymous assignments cannot be hidden by section
- and cannot be used together
- A course with that id does not exist
- Anonymous assignments cannot be posted by graded only
- Anonymous assignments cannot be posted by section
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/a470bbbf40bb3329.
Report an issue: GitHub.
Appendix: source
Thrown at app/graphql/mutations/hide_assignment_grades.rb:47
field :assignment, Types::AssignmentType, null: true
field :progress, Types::ProgressType, null: true
field :sections, [Types::SectionType], null: true
def resolve(input:)
begin
assignment = AbstractAssignment.find_assignment_or_peer_review(input[:assignment_id])
course = assignment.context
sections = input[:section_ids] ? course.course_sections.where(id: input[:section_ids]) : nil
rescue ActiveRecord::RecordNotFound
raise GraphQL::ExecutionError, "not found"
end
verify_authorized_action!(assignment, :grade)
unless assignment.grades_published?
raise GraphQL::ExecutionError, "Assignments under moderation cannot be hidden before grades are published"
end
raise GraphQL::ExecutionError, "Anonymous assignments cannot be posted by section" if sections && assignment.anonymous_grading?
if input[:only_student_ids] && input[:skip_student_ids]
raise GraphQL::ExecutionError, I18n.t("{a} and {b} cannot be used together", a: "only_student_ids", b: "skip_student_ids")
end
visible_enrollments = course.apply_enrollment_visibility(course.student_enrollments, current_user, sections)
visible_enrollments = visible_enrollments.where(user_id: input[:only_student_ids]) if input[:only_student_ids]
visible_enrollments = visible_enrollments.where.not(user_id: input[:skip_student_ids]) if input[:skip_student_ids]
submissions_scope = assignment.submissions.active.joins(user: :enrollments)
submissions_scope = course.apply_enrollment_visibility(submissions_scope, current_user).merge(visible_enrollments)
progress = course.progresses.new(tag: "hide_assignment_grades")
if progress.save
progress.process_job(
assignment,
:hide_submissions,
{ preserve_method_args: true, priority: Delayed::HIGH_PRIORITY },View on GitHub (pinned to 1c9f0bb801)