instructure/canvas-lms · error · ImportError
An old_id, '# ', referenced a non-existent # and was not…
Error message
An old_id, '#{data_change.old_id}', referenced a non-existent #{type} and was not changed. What it means
find_item_to_update raises this when old_id is present, old_integration_id is blank, and no record of the given type matches scope.find_by(sis_source_id/sis_user_id => old_id). The importer cannot re-key a record it cannot find, so the row is rejected with the record left unchanged.
Solutions
- Verify old_id against the current record (e.g. Course.where(root_account:..., sis_source_id: old_id)).
- If the id was already changed, drop or update the stale row in the CSV.
- Confirm the row is being imported into the same root_account that owns the record.
Example fix
// before: id never existed user,U-999,U-1000 // after: use the real current sis id user,U-100,U-1000
Defensive patterns
Strategy: validation
Validate before calling
if dc.old_id.present? && dc.old_integration_id.blank?
unless scope_for(dc.type).where(sis_column_for(dc.type) => dc.old_id).exists?
raise ArgumentError, "unknown #{dc.type} old_id #{dc.old_id}"
end
end
process_change_sis_id(dc) Try / catch
begin
process_change_sis_id(dc)
rescue SIS::ImportError => e
if e.message.include?('non-existent')
logger.warn("stale row for old_id=#{dc.old_id}: skipped")
end
end Prevention
- Regenerate change files from live data immediately before import.
- Scope existence checks to the same root_account used by the import.
- Mark previously applied renames so replays can be dropped.
When it happens
Trigger: change_sis_id row whose old_id does not match any existing sis_source_id (or sis_user_id for type=user) under the root account scope — wrong prefix, wrong account, record already deleted, or id already changed by a previous import.
Common situations: SIS id renamed earlier but CSV still carries the old value, importing into the wrong root_account, case-sensitivity/format mismatches, or referencing soft-deleted records outside the scope.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- An old_integration_id, '#
- A new_id, '# ', referenced an existing # and the # with #…
- A new_integration_id, '#
- A student referenced a non-existent user #
- An old_id, '# ', referenced a different # than the…
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/e84d37baecc7a387.
Report an issue: GitHub.
Appendix: source
Thrown at lib/sis/change_sis_id_importer.rb:147
check_int = details[:scope].where(integration_id: data_change.new_integration_id).exists? if data_change.new_integration_id.present?
raise ImportError, "A new_integration_id, '#{data_change.new_integration_id}', referenced an existing #{type} and the #{type} with integration_id '#{data_change.old_integration_id}' was not updated" if check_int
end
def find_item_to_update(column, details, type, data_change)
if data_change.old_id.present?
old_item = details[:scope].find_by(column => data_change.old_id)
end
if data_change.old_integration_id.present?
old_int_item = details[:scope].find_by(integration_id: data_change.old_integration_id)
end
if data_change.old_id.present? && data_change.old_integration_id.present?
raise ImportError, "An old_id, '#{data_change.old_id}', referenced a different #{type} than the old_integration_id, '#{data_change.old_integration_id}'" unless old_item == old_int_item
return old_item
end
if data_change.old_id.present? && data_change.old_integration_id.blank?
raise ImportError, "An old_id, '#{data_change.old_id}', referenced a non-existent #{type} and was not changed." unless old_item
return old_item
end
if data_change.old_id.blank? && data_change.old_integration_id.present?
raise ImportError, "An old_integration_id, '#{data_change.old_integration_id}', referenced a non-existent #{type} and was not changed." unless old_int_item
old_int_item
end
end
end
end
end
View on GitHub (pinned to 1c9f0bb801)