instructure/canvas-lms · error · Canvas::Migration::Error
$!.message
Error message
$!.message
What it means
Canvas::Migration::Worker#download_attachment rescues Attachment::OverQuotaError and re-raises it as Canvas::Migration::Error with the original message. It means the migration could not attach the file because the context (course/user) exceeded its storage quota.
Solutions
- Increase the course/account storage quota (course advanced settings or account quota settings)
- Remove unused files from the target course to free space, then retry the migration
- Handle the raised message in the UI to show users the quota problem
- For account-level imports, raise default quota via account settings
Example fix
// before
# import fails silently with generic error
// after
begin
Canvas::Migration::Worker.download_attachment(cm, url)
rescue Canvas::Migration::Error => e
if e.message =~ /quota/i
show_quota_error_dialog
end
end Defensive patterns
Strategy: validation
Validate before calling
quota = cm.context.storage_quota used = cm.context.storage_quota_used raise 'over quota' if used + expected_size > quota
Try / catch
begin att = Canvas::Migration::Worker.download_attachment(cm, url) rescue Canvas::Migration::Error => e raise if e.message !~ /quota/i notify_quota_exceeded(cm.context) end
Prevention
- Check remaining quota before starting large imports
- Increase default account quotas for import-heavy workflows
- Clean orphaned/unattached files periodically
When it happens
Trigger: download_attachment (clone_url path) raising Attachment::OverQuotaError when importing course files into a context already at or above its storage quota.
Common situations: Importing a large course export into a course with a small quota, user files quota exceeded during course copy, quota lowered after content was created.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/5b7d66d4ebde06bd.
Report an issue: GitHub.
Appendix: source
Thrown at lib/canvas/migration/worker.rb:102
Rails.logger.warn "Couldn't clear export data for content_migration #{content_migration.id}"
end
def self.download_attachment(cm, url)
att = Attachment.new
att.context = cm
att.file_state = "deleted"
att.workflow_state = "unattached"
att.clone_url(url, false, true, quota_context: cm.context)
if att.file_state == "errored"
raise Canvas::Migration::Error, att.upload_error_message
end
cm.attachment = att
cm.save!
att
rescue Attachment::OverQuotaError
raise Canvas::Migration::Error, $!.message
end
end
View on GitHub (pinned to 1c9f0bb801)