instructure/canvas-lms · error · GraphQL::ExecutionError
Anonymous assignments cannot be posted by graded only
Error message
Anonymous assignments cannot be posted by graded only
What it means
PostAssignmentGrades rejects graded_only when the assignment is anonymous_grading (note: checks the boolean attribute, not the ? predicate). For anonymous assignments 'post grades' is all-or-nothing, so filtering to already-graded submissions is disallowed.
Solutions
- Omit graded_only (or set it false) when assignment.anonymous_grading is true.
- Post once for all students instead of incrementally for anonymous assignments.
- Client-side: disable the graded-only option when anonymous grading is enabled.
Example fix
// before
postAssignmentGrades(input: {assignmentId, gradedOnly: true}) // anonymous assignment
// after
const gradedOnly = assignment.anonymousGrading ? false : true;
postAssignmentGrades(input: {assignmentId, gradedOnly}) Defensive patterns
Strategy: validation
Validate before calling
const gradedOnly = assignment.anonymousGrading ? false : Boolean(gradedOnlyPref);
Try / catch
try { await post(); } catch (e) { if (/graded only/.test(e.message)) { input.gradedOnly = false; await post(); } } Prevention
- Never default graded_only to true for anonymous assignments.
- Keep a single source of truth for the graded-only preference.
- Mirror server validation rules in the client form.
When it happens
Trigger: postAssignmentGrades with input.graded_only=true on an assignment where assignment.anonymous_grading is true.
Common situations: Clients that default graded_only to true (e.g. reusing 'post grades to graded only' checkbox) while the assignment is anonymous.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- and cannot be used together
- and cannot be used together
- Anonymous assignments cannot be hidden by section
- Anonymous assignments cannot be posted by section
- Anonymous assignments cannot be posted by section
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/fb60414b1806e240.
Report an issue: GitHub.
Appendix: source
Thrown at app/graphql/mutations/post_assignment_grades.rb:51
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 posted before grades are published"
end
raise GraphQL::ExecutionError, "Anonymous assignments cannot be posted by section" if sections && assignment.anonymous_grading?
if input[:graded_only] && assignment.anonymous_grading
raise GraphQL::ExecutionError, "Anonymous assignments cannot be posted by graded only"
end
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 = input[:graded_only] ? assignment.submissions.postable : assignment.submissions
submissions_scope = submissions_scope.joins(user: :enrollments).merge(visible_enrollments)
submission_ids = submissions_scope.pluck(:id)
progress = course.progresses.new(tag: "post_assignment_grades")
posting_params = {
graded_only: !!input[:graded_only],
section_names: sections&.pluck(:name)View on GitHub (pinned to 1c9f0bb801)