instructure/canvas-lms · error · InvalidDataError
Outcome with ID already exists in another unrelated course…
Error message
Outcome with ID %{guid} already exists in another unrelated course or account (%{name}) What it means
Raised by Outcomes::Import#import_outcome when an outcome identified by vendor_guid already exists in a context (course or account) that is not a child/ancestor of the importing context. The import refuses to touch outcomes owned by unrelated contexts, since cross-context modification would corrupt outcome ownership. The existing outcome's context name is included in the message to help locate it.
Solutions
- Check which context already owns the outcome (the %{name} in the message) and import into that context or a child of it.
- Change the vendor_guid in the import file so it no longer collides with the unrelated outcome.
- Delete or re-purpose the pre-existing outcome if it was created by mistake, then re-run the import.
- Import the outcome at a common ancestor account so both contexts are within the same hierarchy.
Example fix
// before: importing a package with vendor_guid 'X' already owned by Account A, from unrelated Account B
// after: re-key the guid in the import JSON
{
"vendor_guid": "X-account-B",
"title": "Outcome"
} Defensive patterns
Strategy: validation
Validate before calling
// Ruby: pre-check ownership before importing def importable?(vendor_guid, context) lo = LearningOutcome.find_by(vendor_guid: vendor_guid) lo.nil? || context == lo.context || context.account_chain.include?(lo.context) end
Try / catch
begin
importer.import_object(...)
rescue Outcomes::Import::InvalidDataError => e
Rails.logger.warn("Outcome ownership conflict: #{e.message}")
# skip row or re-key guid and retry
end Prevention
- Keep vendor_guids globally unique (prefix with your institution/account id).
- Import only exports generated from the same account hierarchy.
- Check the %{name} in the message to find the conflicting context before re-running.
When it happens
Trigger: Importing a course/account outcome export whose vendor_guid matches a LearningOutcome in a completely unrelated course or root account; child_context?(context, of: model.context) returns false in import_outcome (lib/outcomes/import.rb:156).
Common situations: Re-importing an outcome package originally exported from a different institution/account; a vendor_guid collision where two courses reuse the same GUID; copying outcome import files between Canvas accounts without re-keying vendor_guids.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Cannot modify outcome from another context
- Outcome " " has already appeared in this import
- Cyclic reference detected when importing
- Database error ( )
- Error importing outcomes
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/b6135ec1b2aa468f.
Report an issue: GitHub.
Appendix: source
Thrown at lib/outcomes/import.rb:156
model
end
def import_outcome(outcome)
invalid = outcome.keys.select do |k|
outcome[k].present? && GROUP_ONLY_FIELDS.include?(k)
end
if invalid.present?
raise InvalidDataError, I18n.t(
"Invalid fields for an outcome: %{invalid}",
invalid: invalid.map(&:to_s).inspect
)
end
model = find_prior_outcome(outcome)
model.context = context if model.new_record?
unless child_context?(context, of: model.context)
raise InvalidDataError, I18n.t(
"Outcome with ID %{guid} already exists in another unrelated course or account (%{name})",
guid: outcome[:vendor_guid],
name: model.context.name
)
end
allow_indirect = outcome.key?(:course_id)
parents = find_parents(outcome, context, allow_indirect:)
if model.outcome_import_id == outcome_import_id
raise InvalidDataError, I18n.t(
'Outcome "%{guid}" has already appeared in this import',
guid: outcome[:vendor_guid]
)
end
model.vendor_guid = outcome[:vendor_guid]
model.title = outcome[:title]View on GitHub (pinned to 1c9f0bb801)