{"record":{"id":"a448a18cf0046c8f","repo":"instructure/canvas-lms","slug":"assignment-not-found","errorCode":null,"errorMessage":"Assignment not found","messagePattern":"Assignment not found","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/allocation_rule_base.rb","lineNumber":117,"sourceCode":"      if assessor_ids.empty?\n        raise GraphQL::ExecutionError, I18n.t(\"At least one assessor is required\")\n      end\n      if assessee_ids.empty?\n        raise GraphQL::ExecutionError, I18n.t(\"At least one assessee is required\")\n      end\n\n      if assessor_ids.length > 50\n        raise GraphQL::ExecutionError, I18n.t(\"A maximum of 50 assessors can be provided at once\")\n      end\n      if assessee_ids.length > 50\n        raise GraphQL::ExecutionError, I18n.t(\"A maximum of 50 assessees can be provided at once\")\n      end\n    end\n\n    def get_assignment(assignment_id)\n      Assignment.active.find(assignment_id)\n    rescue ActiveRecord::RecordNotFound\n      raise GraphQL::ExecutionError, I18n.t(\"Assignment not found\")\n    end\n\n    def process_allocation_rules(allocation_rules)\n      if allocation_rules.all?(&:valid?)\n        allocation_rules.each(&:save!)\n        { allocation_rules: }\n      else\n        invalid_rules = allocation_rules.reject(&:valid?)\n        all_allocation_errors = []\n\n        invalid_rules.each do |invalid_rule|\n          rule_errors = allocation_errors_for(invalid_rule)\n          all_allocation_errors.concat(rule_errors[:allocation_errors])\n        end\n\n        {\n          allocation_errors: all_allocation_errors\n        }","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/allocation_rule_base.rb#L99-L135","documentation":"Raised by get_assignment in AllocationRuleBase when Assignment.active.find(assignment_id) raises ActiveRecord::RecordNotFound, i.e. no active assignment with the given ID exists (missing, deleted, or soft-deleted via a non-'active' workflow state). It is converted into a GraphQL ExecutionError 'Assignment not found'.","triggerScenarios":"Calling an allocation-rule mutation with an assignmentId that does not exist, belongs to a deleted assignment (workflow_state != 'active'), is on the wrong shard/root account, or is a malformed/nonexistent ID in the environment.","commonSituations":"Staging IDs used against production data; the assignment was deleted after the UI loaded; the assignment is 'soft deleted' so active scope excludes it; cross-shard ID handling issues in multi-shard Canvas installs.","solutions":["Verify the assignmentId exists: Assignment.active.find(id) in the Rails console on the correct shard.","Check the assignment's workflow_state — a deleted assignment will not be found by the active scope.","Refresh the client's assignment data; the assignment may have been deleted after page load.","Confirm you are operating on the correct Canvas environment/shard and root account."],"exampleFix":"// before\nmutation { createAllocationRules(input: { assignmentId: \"999999\", ... }) } // ID deleted/nonexistent\n// after: resolve a live assignment first\nassignment = course.assignments.active.where(name: \"Peer Review 1\").first!\n# use assignment.id (GlobalID string) in the mutation input","handlingStrategy":"try-catch","validationCode":"const assignment = await canvasApi.getAssignment(courseId, assignmentId);\nif (!assignment || assignment.workflow_state !== 'active') {\n  throw new Error(`Assignment ${assignmentId} is missing or not active`);\n}\n// then run the allocation rule mutation","typeGuard":"function isActiveAssignment(a) {\n  return a != null && typeof a.id === 'string' && a.workflow_state === 'active';\n}","tryCatchPattern":"try {\n  await createAllocationRules({ assignmentId, ... });\n} catch (e) {\n  if (e.message.includes('Assignment not found')) {\n    // refetch assignment list; id may be deleted or from another environment\n  }\n}","preventionTips":["Resolve assignment IDs from a fresh API query, never hardcode across environments","Check workflow_state is 'active' (deleted assignments are excluded by the active scope)","Be aware of shard/root-account scoping in multi-shard installs","Handle assignments deleted after page load by refreshing before submit"],"tags":["graphql","not-found","assignment","canvas"],"backgroundTag":"record-not-found","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"}