{"record":{"id":"0ac1ffc8f2706ac8","repo":"instructure/canvas-lms","slug":"no-such-source-context","errorCode":null,"errorMessage":"no such source context","messagePattern":"no such source context","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/import_outcomes.rb","lineNumber":50,"sourceCode":"\n  field :progress, Types::ProgressType, null: true\n\n  VALID_CONTEXTS = %w[Account Course].freeze\n\n  def resolve(input:)\n    source_context = nil\n    if input[:source_context_type].present?\n      if input[:source_context_id].present?\n        begin\n          source_context = context_class(input[:source_context_type]).find_by(id: input[:source_context_id])\n        rescue NameError\n          return validation_error(\n            I18n.t(\"invalid value\"), attribute: \"sourceContextType\"\n          )\n        end\n\n        if source_context.nil?\n          raise GraphQL::ExecutionError, I18n.t(\"no such source context\")\n        end\n      else\n        return validation_error(\n          I18n.t(\"sourceContextId required if sourceContextType provided\"),\n          attribute: \"sourceContextId\"\n        )\n      end\n    elsif input[:source_context_id].present?\n      return validation_error(\n        I18n.t(\"sourceContextType required if sourceContextId provided\"),\n        attribute: \"sourceContextType\"\n      )\n    end\n\n    target_context, target_group = get_target(input)\n\n    verify_authorized_action!(target_context, :manage_outcomes)\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/import_outcomes.rb#L32-L68","documentation":"ImportOutcomes mutation raises this when sourceContextType/sourceContextId were provided, the type is valid (Account or Course), but no active record with that id exists. The mutation requires the source context to be a real Account or Course before importing outcomes from it.","triggerScenarios":"Calling importOutcomes with sourceContextType:'Account' or 'Course' plus a sourceContextId that matches no record — deleted account/course, wrong shard id, id from another environment, or a numeric legacy id where a global relay id is needed (or vice versa).","commonSituations":"Copying requests between prod/staging; referencing a course deleted via course cleanup jobs; cross-shard ids without the proper shard-scoped global id; typos in the id; sourceContextId of a User or other non-Account/Course type.","solutions":["Verify the sourceContextId exists via GraphQL node query or rails console (Account.find / Course.find)","Ensure id format matches expectations (legacy numeric vs relay global id)","Check you are querying the correct shard/root account for the id","Confirm the Account/Course was not deleted; pick an existing source context"],"exampleFix":"// before\nimportOutcomes(input: { sourceContextId: \"999999\", sourceContextType: \"Course\", targetGroupId: \"5\", groupId: \"3\" })\n// after: verify first\nconst ctx = await node({ id: toGlobalId(\"Course\", \"999999\") }); // must not be null\nimportOutcomes(input: { sourceContextId: \"1234\", sourceContextType: \"Course\", targetGroupId: \"5\", groupId: \"3\" });","handlingStrategy":"validation","validationCode":"const node = await graphqlClient.node(toGlobalId(sourceContextType, sourceContextId));\nif (!node) throw new Error(`source context ${sourceContextType}#${sourceContextId} does not exist`);","typeGuard":"const isSourceContext = (n) => n && [\"Account\", \"Course\"].includes(n.__typename);","tryCatchPattern":"try {\n  await importOutcomes(input);\n} catch (e) {\n  if (e.message === \"no such source context\") {\n    // re-resolve source context id or omit sourceContext to let the group define it\n  }\n}","preventionTips":["Omit sourceContextId/sourceContextType unless you specifically need to assert it — it is optional","Resolve ids via GraphQL node lookups, not cached/dumped values","Mind cross-shard global id formats","Confirm the Account/Course is not deleted before importing"],"tags":["graphql","resource-not-found","canvas-lms","outcomes"],"backgroundTag":"entity-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"}