instructure/canvas-lms · error · GraphQL::ExecutionError

no such target group

Error message

no such target group

What it means

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.

Solutions

  1. Verify: LearningOutcomeGroup.active.find_by(id: target_group_id) in rails console
  2. Fetch a fresh target group id via GraphQL (context outcomeGroups/rootOutcomeGroup) before importing
  3. Confirm you did not swap groupId (source) and targetGroupId
  4. Check shard/root-account scoping of the id

Example fix

// before: stale target id
importOutcomes(input: { groupId: "7", targetGroupId: "deleted-99" })
// after: resolve the context root group freshly
const target = await account.rootOutcomeGroup;
importOutcomes(input: { groupId: "7", targetGroupId: target.id });
Defensive patterns

Strategy: validation

Validate before calling

const t = await graphqlClient.node(toGlobalId("LearningOutcomeGroup", targetGroupId));
if (!t || t.workflowState !== "active") throw new Error("no such target group");

Type guard

const isValidTargetGroup = (g) => g && g.workflowState === "active";

Try / catch

try {
  await importOutcomes(input);
} catch (e) {
  if (e.message === "no such target group") {
    // fall back to the context's rootOutcomeGroup as the target
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/c7644508e23ac8bf. Report an issue: GitHub.

Appendix: source

Thrown at app/graphql/mutations/import_outcomes.rb:312

      group = source_group.clone
      group.root_account_id = target_group.context.resolved_root_account_id
      group.learning_outcome_group_id = destination_parent_group.id
      group.source_outcome_group_id = source_group.id
      group.context = target_group.context
      group.save!

      group
    end
  end

  private

  def get_target(input)
    if input[:target_group_id]
      target_group = LearningOutcomeGroup.active.find_by(id: input[:target_group_id])
      if target_group.nil?
        raise GraphQL::ExecutionError, I18n.t("no such target group")
      end

      target_context = target_group.context

      [target_context, target_group]
    else
      if input[:target_context_type].blank? && input[:target_context_id].blank?
        raise GraphQL::ExecutionError, I18n.t(
          "You must provide targetGroupId or targetContextId and targetContextType"
        )
      elsif input[:target_context_type].blank? && input[:target_context_id].present?
        raise GraphQL::ExecutionError, I18n.t(
          "targetContextType required if targetContextId provided"
        )
      elsif input[:target_context_type].present? && input[:target_context_id].blank?
        raise GraphQL::ExecutionError, I18n.t(
          "targetContextId required if targetContextType provided"
        )

View on GitHub (pinned to 1c9f0bb801)