{"record":{"id":"fb60414b1806e240","repo":"instructure/canvas-lms","slug":"anonymous-assignments-cannot-be-posted-by-graded-only","errorCode":null,"errorMessage":"Anonymous assignments cannot be posted by graded only","messagePattern":"Anonymous assignments cannot be posted by graded only","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/post_assignment_grades.rb","lineNumber":51,"sourceCode":"\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\n    posting_params = {\n      graded_only: !!input[:graded_only],\n      section_names: sections&.pluck(:name)","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/post_assignment_grades.rb#L33-L69","documentation":"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.","triggerScenarios":"postAssignmentGrades with input.graded_only=true on an assignment where assignment.anonymous_grading is true.","commonSituations":"Clients that default graded_only to true (e.g. reusing 'post grades to graded only' checkbox) while the assignment is anonymous.","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."],"exampleFix":"// before\npostAssignmentGrades(input: {assignmentId, gradedOnly: true}) // anonymous assignment\n// after\nconst gradedOnly = assignment.anonymousGrading ? false : true;\npostAssignmentGrades(input: {assignmentId, gradedOnly})","handlingStrategy":"validation","validationCode":"const gradedOnly = assignment.anonymousGrading ? false : Boolean(gradedOnlyPref);","typeGuard":null,"tryCatchPattern":"try { await post(); } catch (e) { if (/graded only/.test(e.message)) { input.gradedOnly = false; await post(); } }","preventionTips":["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."],"tags":["graphql","anonymous-grading","input-validation"],"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"}