{"record":{"id":"c7644508e23ac8bf","repo":"instructure/canvas-lms","slug":"no-such-target-group","errorCode":null,"errorMessage":"no such target group","messagePattern":"no such target group","errorType":"exception","errorClass":"GraphQL::ExecutionError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/import_outcomes.rb","lineNumber":312,"sourceCode":"\n      group = source_group.clone\n      group.root_account_id = target_group.context.resolved_root_account_id\n      group.learning_outcome_group_id = destination_parent_group.id\n      group.source_outcome_group_id = source_group.id\n      group.context = target_group.context\n      group.save!\n\n      group\n    end\n  end\n\n  private\n\n  def get_target(input)\n    if input[:target_group_id]\n      target_group = LearningOutcomeGroup.active.find_by(id: input[:target_group_id])\n      if target_group.nil?\n        raise GraphQL::ExecutionError, I18n.t(\"no such target group\")\n      end\n\n      target_context = target_group.context\n\n      [target_context, target_group]\n    else\n      if input[:target_context_type].blank? && input[:target_context_id].blank?\n        raise GraphQL::ExecutionError, I18n.t(\n          \"You must provide targetGroupId or targetContextId and targetContextType\"\n        )\n      elsif input[:target_context_type].blank? && input[:target_context_id].present?\n        raise GraphQL::ExecutionError, I18n.t(\n          \"targetContextType required if targetContextId provided\"\n        )\n      elsif input[:target_context_type].present? && input[:target_context_id].blank?\n        raise GraphQL::ExecutionError, I18n.t(\n          \"targetContextId required if targetContextType provided\"\n        )","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/graphql/mutations/import_outcomes.rb#L294-L330","documentation":"ImportOutcomes' get_target helper raises this when targetGroupId is provided but no ACTIVE LearningOutcomeGroup with that id exists. The target group is where imported outcomes/groups will be placed; a deleted or nonexistent id aborts the mutation.","triggerScenarios":"Calling importOutcomes with targetGroupId of a deleted group, a wrong-typed id, an id from a different shard/root account, or passing the groupId as targetGroupId by mistake.","commonSituations":"Target folder deleted by another admin between page load and import; copy-pasting source groupId into targetGroupId; environment-mismatched ids; using a soft-deleted group's cached id.","solutions":["Verify: LearningOutcomeGroup.active.find_by(id: target_group_id) in rails console","Fetch a fresh target group id via GraphQL (context outcomeGroups/rootOutcomeGroup) before importing","Confirm you did not swap groupId (source) and targetGroupId","Check shard/root-account scoping of the id"],"exampleFix":"// before: stale target id\nimportOutcomes(input: { groupId: \"7\", targetGroupId: \"deleted-99\" })\n// after: resolve the context root group freshly\nconst target = await account.rootOutcomeGroup;\nimportOutcomes(input: { groupId: \"7\", targetGroupId: target.id });","handlingStrategy":"validation","validationCode":"const t = await graphqlClient.node(toGlobalId(\"LearningOutcomeGroup\", targetGroupId));\nif (!t || t.workflowState !== \"active\") throw new Error(\"no such target group\");","typeGuard":"const isValidTargetGroup = (g) => g && g.workflowState === \"active\";","tryCatchPattern":"try {\n  await importOutcomes(input);\n} catch (e) {\n  if (e.message === \"no such target group\") {\n    // fall back to the context's rootOutcomeGroup as the target\n  }\n}","preventionTips":["Resolve the target group freshly (e.g. context.rootOutcomeGroup) rather than caching ids","Verify groupId and targetGroupId are not swapped","Restrict target pickers to active groups in the target's context"],"tags":["graphql","resource-not-found","outcomes","canvas-lms"],"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"}