instructure/canvas-lms · error · GraphQL::ExecutionError
not found
Error message
not found
What it means
PostAssignmentGrades mutation resolves the assignment via AbstractAssignment.find_assignment_or_peer_review; if the id does not resolve (or course/section lookup raises RecordNotFound inside the same begin block), it is translated into a generic GraphQL 'not found' ExecutionError.
Solutions
- Verify the assignment exists: Assignment.find(id) in console, and that it is in the same course.
- Use the assignment's global or correct-shard id; confirm peer-review sub-assignments only where intended.
- Check the assignment was not deleted (workflow_state != 'deleted') and re-fetch fresh ids.
Example fix
// before
postAssignmentGrades(input: {assignmentId: "1234", ...}) // deleted/stale id
// after
const assignment = await fetchAssignment(id); // 404-check before posting
if (!assignment) return; // surface a friendly 'assignment no longer exists' message Defensive patterns
Strategy: validation
Validate before calling
if (!assignmentId) throw new Error('assignmentId required');
const assignment = await fetchAssignment(assignmentId); // expect 200
if (!assignment) return notFound(); Type guard
const isValidAssignment = (a) => a && typeof a.id === 'string' && a.id.length > 0;
Try / catch
try { await postAssignmentGrades({input}); } catch (e) { if (e.message === 'not found') notifyStaleAssignment(); else throw e; } Prevention
- Re-fetch assignment ids from the API instead of caching them across sessions.
- Use global ids when crossing shard boundaries.
- Handle deletions in the UI so stale ids cannot be submitted.
When it happens
Trigger: Posting grades with an assignmentId that is deleted, nonexistent, belongs to another course/shard, or is not an assignment or peer-review sub-assignment.
Common situations: Stale client-side IDs after an assignment deletion; copying IDs across Canvas shards/environments; passing a discussion topic or quiz id instead of its assignment id.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- assignment not found
- Allocation rule not found
- Assignment group category id and discussion topic group…
- Assignment not found
- assignment not found: #
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/1dce8eb9a92f8964.
Report an issue: GitHub.
Appendix: source
Thrown at app/graphql/mutations/post_assignment_grades.rb:40
graphql_name "PostAssignmentGrades"
argument :assignment_id, ID, required: true, prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func("Assignment")
argument :graded_only, Boolean, required: false
argument :only_student_ids, [ID], required: false, prepare: GraphQLHelpers.relay_or_legacy_ids_prepare_func("User")
argument :section_ids, [ID], required: false, prepare: GraphQLHelpers.relay_or_legacy_ids_prepare_func("Section")
argument :skip_student_ids, [ID], required: false, prepare: GraphQLHelpers.relay_or_legacy_ids_prepare_func("User")
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 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)View on GitHub (pinned to 1c9f0bb801)