instructure/canvas-lms · error · GraphQL::ExecutionError
Assignment not found
Error message
Assignment not found
What it means
create_allocation_rule#get_assignment looks up Assignment.active.find(assignment_id); if no active assignment matches, ActiveRecord::RecordNotFound is rescued and re-raised as 'Assignment not found'. Deleted/concluded (non-active) assignments are treated as nonexistent.
Solutions
- Verify the assignment id exists and its workflow_state is active (Assignment.active scope)
- Re-fetch assignment ids from the API instead of using cached ones
- Check you are passing a valid Assignment relay/legacy id on the correct shard
- If the assignment was deleted, restore it or choose another assignment
Example fix
// before
createAllocationRule(input: { assignmentId: "12" }) // assignment deleted
// after
// resolve fresh id first:
assignment = course.assignments.active.find { |a| a.name == "HW1" }
createAllocationRule(input: { assignmentId: assignment.relay_id }) Defensive patterns
Strategy: validation
Validate before calling
const asg = await canvas.get(`/api/v1/courses/${courseId}/assignments/${assignmentId}`)
if (!asg || asg.deleted_at) throw new Error('assignment missing or deleted') Type guard
function isActiveAssignment(a) { return a != null && a.id != null && a.workflow_state === 'published' && !a.deleted_at } Try / catch
try {
await client.mutate({ mutation: CREATE_ALLOCATION_RULE, variables: { assignmentId } })
} catch (e) {
if (e.message.includes('Assignment not found')) {
assignmentId = await refetchActiveAssignmentId(courseId)
// retry once with fresh id
} else throw e
} Prevention
- Always resolve assignment ids fresh from the assignments API
- Filter out deleted/concluded assignments client-side
- Use consistent id formats (legacy numeric vs relay) per endpoint
- Watch for cross-shard ids when multi-shard setups are in play
When it happens
Trigger: Calling createAllocationRule with an assignmentId that is deleted,soft-deleted, on a different shard, or a non-assignment id; also plain nonexistent ids.
Common situations: Client cached an assignment id that was later deleted; id passed belongs to a quiz-lti assignment not in the active scope; cross-shard id format mismatch.
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
- An assignment with that id does not exist
- Course not found
- custom grade status not found
- not found
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/ed3db926e227245f.
Report an issue: GitHub.
Appendix: source
Thrown at app/graphql/mutations/create_allocation_rule.rb:78
target_id = input[:applies_to_assessor] ? input[:assessor_ids].first : input[:assessee_ids].first
subjects = input[:applies_to_assessor] ? input[:assessee_ids] : input[:assessor_ids]
subjects.each do |subject_id|
opts = {
assessor_id: input[:applies_to_assessor] ? target_id : subject_id,
assessee_id: input[:applies_to_assessor] ? subject_id : target_id
}
allocation_rules << create_or_find_new_rule(assignment, course, opts.merge(shared_opts))
end
end
allocation_rules
end
def get_assignment(assignment_id)
Assignment.active.find(assignment_id)
rescue ActiveRecord::RecordNotFound
raise GraphQL::ExecutionError, I18n.t("Assignment not found")
end
end
View on GitHub (pinned to 1c9f0bb801)