instructure/canvas-lms · error · GraphQL::ExecutionError
Assignments under moderation cannot be hidden by section…
Error message
Assignments under moderation cannot be hidden by section before grades are published
What it means
Section-based hiding is forbidden on assignments still under moderated grading whose grades have not been published (grades_published? false), mirroring the general mutation but with a section-specific message. Provisional grades must be finalized before any section-scoped posting/hide operation.
Solutions
- Have a moderator publish grades for the assignment first (grades_published!), then retry the section hide.
- Check grades_published_at / gradesPublished via GraphQL before calling and block the action in the UI.
- If moderated grading is unnecessary, disable it before grading begins.
- Coordinate with the moderation workflow (moderation setters) rather than bypassing with direct DB updates.
Example fix
// before
await HideBySection.mutate({ assignmentId, sectionIds });
// after
const a = await fetchAssignment(assignmentId);
if (a.moderatedGrading && !a.gradesPublished) {
notifyModerator(assignmentId);
return; // wait for publish
}
await HideBySection.mutate({ assignmentId, sectionIds }); Defensive patterns
Strategy: validation
Validate before calling
const a = await fetchAssignment(assignmentId);
if (a.moderatedGrading && !a.gradesPublished) throw new SkipError('Grades not published yet'); Type guard
const sectionHideAllowed = (a) => Boolean(a && a.gradesPublished === true);
Try / catch
try { await hideBySection({ assignmentId, sectionIds }); }
catch (e) {
if (String(e).includes('grades are published')) { await notifyModerator(assignmentId); return; }
throw e;
} Prevention
- Gate section-hide UI on gradesPublished
- Align automation with the moderation workflow timelines
- Check assignment.moderatedGrading flag in queries
- Educate graders that only moderators publish final grades
When it happens
Trigger: Calling hideAssignmentGradesForSections for an assignment with moderated_grading enabled before the moderator publishes final grades.
Common situations: Departmental workflows where different sections are moderated independently and a teacher assumes their section is done; scheduled scripts hiding grades by section after term end without checking publication state.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Assignments under moderation cannot be hidden before grades…
- Moderated assignments must be manually posted until grades…
- and cannot be used together
- A course with that id does not exist
- Anonymous assignments cannot be hidden by section
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/326e2907c64be349.
Report an issue: GitHub.
Appendix: source
Thrown at app/graphql/mutations/hide_assignment_grades_for_sections.rb:43
argument :section_ids, [ID], required: true, prepare: GraphQLHelpers.relay_or_legacy_ids_prepare_func("Section")
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 = course.course_sections.where(id: input[:section_ids])
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 by section before grades are published"
end
raise GraphQL::ExecutionError, "Anonymous assignments cannot be hidden by section" if assignment.anonymize_students?
if sections.empty? || sections.count != input[:section_ids].size
raise GraphQL::ExecutionError, "Invalid section ids"
end
visible_enrollments = course.apply_enrollment_visibility(course.student_enrollments, current_user, sections)
submissions_scope = input[:graded_only] ? assignment.submissions.graded : assignment.submissions
submissions_scope = submissions_scope.joins(user: :enrollments).merge(visible_enrollments)
progress = course.progresses.new(tag: "hide_assignment_grades_for_sections")
if progress.save
progress.process_job(
assignment,
:hide_submissions,View on GitHub (pinned to 1c9f0bb801)