{"record":{"id":"ab4978b93b9e1923","repo":"instructure/canvas-lms","slug":"error-hiding-assignment-grades","errorCode":null,"errorMessage":"Error hiding assignment grades","messagePattern":"Error hiding assignment grades","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/hide_assignment_grades.rb","lineNumber":72,"sourceCode":"    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 = assignment.submissions.active.joins(user: :enrollments)\n    submissions_scope = course.apply_enrollment_visibility(submissions_scope, current_user).merge(visible_enrollments)\n    progress = course.progresses.new(tag: \"hide_assignment_grades\")\n\n    if progress.save\n      progress.process_job(\n        assignment,\n        :hide_submissions,\n        { preserve_method_args: true, priority: Delayed::HIGH_PRIORITY },\n        progress:,\n        submission_ids: submissions_scope.pluck(:id),\n        skip_content_participation_refresh: false\n      )\n      { assignment:, progress:, sections: }\n    else\n      raise GraphQL::ExecutionError, \"Error hiding assignment grades\"\n    end\n  end\nend\n","sourceCodeStart":54,"sourceCodeEnd":76,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/hide_assignment_grades.rb#L54-L76","documentation":"A terminal fallback: the mutation initiated the hide job but the resulting Progress object did not end up completed/queued as expected (the post/hide operation returned without success), so it raises a generic 'Error hiding assignment grades'. This indicates the internal post_grades/hide flow (Submission.count > 0 guard / PostAssignmentGrades job scheduling) failed rather than an input problem.","triggerScenarios":"There are zero submissions in scope for the hidden operation so the underlying posting service reports nothing was done; the asynchronous posting job fails to enqueue or the Progress never reaches a queued/completed state; an exception inside the posting service swallowed upstream results in a falsy progress.","commonSituations":"Hiding on an assignment where no grades were ever posted (no submissions with posted_at); gradebook plugins/late policies interfering; background job infrastructure (Delayed::Job/SQS) down; Canvas version changes to the posting workflow.","solutions":["Check that the targeted submissions actually have posted grades: query submissions' posted_at/score for the assignment/students in scope.","Inspect Rails/Delayed::Job logs and the Progresses table for the failed job; retry once job infrastructure is healthy.","Verify there is at least one graded submission matching the student/section filters before calling; expand filters if empty.","If reproducible, upgrade Canvas or check for known regressions in app/models/services/post_assignment_grades.rb flow."],"exampleFix":"// before\nawait HideAssignmentGrades.mutate({ assignmentId, sectionIds });\n// after\nconst subs = await api.get(`/courses/${cid}/assignments/${aid}/submissions`);\nconst posted = subs.filter(s => s.posted_at);\nif (!posted.length) { console.warn('Nothing to hide: no posted submissions'); return; }\ntry { await HideAssignmentGrades.mutate({ assignmentId, sectionIds }); }\ncatch (e) { if (String(e).includes('Error hiding assignment grades')) await pollProgressAndRetry(); else throw e; }","handlingStrategy":"try-catch","validationCode":"const posted = submissions.filter(s => s.posted_at);\nif (!posted.length) { console.warn('No posted submissions to hide'); return; }","typeGuard":"const hasHideableWork = (submissions) => Array.isArray(submissions) && submissions.some(s => s.posted_at != null);","tryCatchPattern":"try {\n  const res = await hideGrades({ assignmentId, sectionIds });\n  const progress = res?.data?.hideAssignmentGrades?.progress;\n  if (progress?.state === 'failed') throw new Error('Hide job failed: ' + progress.message);\n} catch (e) {\n  if (String(e).includes('Error hiding assignment grades')) {\n    await checkJobInfrastructureAndLogs();\n    await retryWithBackoff(() => hideGrades({ assignmentId, sectionIds }), 2);\n    return;\n  }\n  throw e;\n}","preventionTips":["Confirm posted submissions exist for the scope before calling","Monitor Delayed::Job/SQS health for the Canvas instance","Check the Progress object state after the mutation, not just GraphQL success","Keep Canvas updated; inspect post_assignment_grades service logs on recurrence"],"tags":["graphql","background-job","canvas-lms","internal-error"],"backgroundTag":"api-error-response","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"}