instructure/canvas-lms · error · InvalidDataError
Group with ID already exists in another unrelated course or…
Error message
Group with ID %{guid} already exists in another unrelated course or account (%{name}) What it means
find_prior_group locates an existing LearningOutcomeGroup by vendor_guid (falling back across contexts). If the found group's context is not the target group_context, the guid is already used by an unrelated course/account, and the import raises this error instead of hijacking or duplicating that group. The message includes the owning context's name.
Solutions
- Use unique vendor_guids per context — prefix or namespace them (e.g. 'myorg.math.group1').
- Import into the context that already owns the group with that guid, or the account that can see it.
- Delete/rename the conflicting group first, or pick a new vendor_guid for the imported group.
- If the existing group is in a related context your account owns, verify how find_prior_group resolves guids and adjust the import context accordingly.
Example fix
// before
{ object_type: 'group', vendor_guid: 'group-1' } # already used in Course A
// after
{ object_type: 'group', vendor_guid: 'dept-b.group-1' } Defensive patterns
Strategy: validation
Validate before calling
existing = LearningOutcomeGroup.where(vendor_guid: guids).joins(:context)
conflicts = existing.select { |g| g.context_id != target_context.id }
raise ArgumentError, "guids owned elsewhere: #{conflicts.map(&:vendor_guid)}" if conflicts.any? Try / catch
begin
importer.import_group(group)
rescue Outcomes::Import::InvalidDataError => e
failures << {vendor_guid: group[:vendor_guid], error: e.message}
end Prevention
- Namespace vendor_guids per source/context
- Preflight guid collisions against existing groups in target context
- Never reuse template or demo guids in production data
When it happens
Trigger: Importing a group whose vendor_guid matches a group that already lives in a different course or account; reusing global vendor_guids (e.g. 'group-1') across multiple courses; a group was moved/merged since the mapping was made.
Common situations: CSVs exported from one account replayed into another; template courses cloned where each copy kept the same vendor_guids; test data with placeholder guids colliding with real records.
Related errors
- A new_id, '# ', referenced an existing # and the # with #…
- A new_integration_id, '#
- An outcome group can only have one parent
- Course with canvas id
- Group " " has already appeared in this import
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/9d8a4e4056f053cc.
Report an issue: GitHub.
Appendix: source
Thrown at lib/outcomes/import.rb:108
if group_context.nil?
raise InvalidDataError, I18n.t(
"Course with canvas id %{id} not found",
id: group[:course_id]
)
end
unless child_context?(group_context)
raise InvalidDataError, I18n.t(
"Target course %{course_id} is not a child of current account (%{name})",
course_id: group[:course_id],
name: context.name
)
end
end
model = find_prior_group(group, group_context)
unless model.context == group_context
raise InvalidDataError, I18n.t(
"Group with ID %{guid} already exists in another unrelated course or account (%{name})",
guid: group[:vendor_guid],
name: model.context.name
)
end
parents = find_parents(group, group_context, model:)
raise InvalidDataError, I18n.t("An outcome group can only have one parent") if parents.length > 1
parent = parents.first
if model.outcome_import_id == outcome_import_id
raise InvalidDataError, I18n.t(
'Group "%{guid}" has already appeared in this import',
guid: group[:vendor_guid]
)
end
model.vendor_guid = group[:vendor_guid]View on GitHub (pinned to 1c9f0bb801)