instructure/canvas-lms · error · GraphQL::ExecutionError
cannot import a root group
Error message
cannot import a root group
What it means
ImportOutcomes raises this when the requested source group is a root outcome group (learning_outcome_group_id is nil) — i.e. the top-level container for a context's outcomes. Root groups represent the whole context's outcome library and cannot be imported as a group; import individual outcomes instead.
Solutions
- Import individual outcomes with outcomeId instead of the root groupId
- Use a non-root child group (learning_outcome_group_id not nil) as groupId
- Check the group: LearningOutcomeGroup.find(id).learning_outcome_group_id — if nil it is a root group and cannot be imported
- Enumerate child_outcome_groups.active of the root group and import those
Example fix
// before: root group
importOutcomes(input: { groupId: account.rootOutcomeGroup.id, targetGroupId: "5" })
// after: import a child group or individual outcomes
importOutcomes(input: { groupId: account.rootOutcomeGroup.childGroups[0].id, targetGroupId: "5" }); Defensive patterns
Strategy: validation
Validate before calling
const g = await graphqlClient.node(toGlobalId("LearningOutcomeGroup", groupId));
if (g.parentOutcomeGroup == null) throw new Error("cannot import a root group — pick a child group or individual outcomes"); Type guard
const isImportableGroup = (g) => g && g.parentOutcomeGroup != null;
Try / catch
try {
await importOutcomes({ groupId, ...target });
} catch (e) {
if (e.message === "cannot import a root group") {
// switch to outcomeId-based import or select a child group
}
} Prevention
- Disable the root group as an import source in the UI (check parentOutcomeGroup)
- Import child groups or individual outcomes instead of the library root
- Remember context.rootOutcomeGroup is a container, not an importable unit
When it happens
Trigger: Calling importOutcomes with groupId set to a context's root outcome group id (the id often returned by context.rootOutcomeGroup); passing an account's or course's top-level group fetched from the outcomes UI root.
Common situations: Selecting 'All outcomes' / the root folder in the UI and importing it; using target_context.root_outcome_group.id as the source groupId; assuming root groups are importable like normal folders.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Auto-grading failed due to the following issue(s): #
- Invalid context type
- Invalid section ids
- Outcome is not available in context #
- Outcome is not available in context #
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/8e593cbff66e1aff.
Report an issue: GitHub.
Appendix: source
Thrown at app/graphql/mutations/import_outcomes.rb:90
if group.nil?
raise GraphQL::ExecutionError, I18n.t("group not found")
end
# If optional source context provided, then check that
# matches the group's context
source_context ||= group.context
if source_context && source_context != group.context
raise GraphQL::ExecutionError, I18n.t("source context does not match group context")
end
# source has to be global or in an associated account
unless !source_context || target_context.associated_accounts.include?(source_context)
raise GraphQL::ExecutionError, I18n.t("invalid context for group")
end
# source can't be a root group
if group.learning_outcome_group_id.nil?
raise GraphQL::ExecutionError, I18n.t("cannot import a root group")
end
return process_job(
source_context:, group:, target_group:
)
elsif (outcome_id = input[:outcome_id].presence)
# Import the selected outcome into the given group
# verify the outcome is eligible to be linked into the group's context
unless target_context.available_outcome(outcome_id, allow_global: true)
raise GraphQL::ExecutionError, I18n.t(
"Outcome %{outcome_id} is not available in context %{context_type}#%{context_id}",
outcome_id:,
context_id: target_context.id.to_s,
context_type: target_context.class.name
)
end
View on GitHub (pinned to 1c9f0bb801)