instructure/canvas-lms · warning · ImportError
Improper status # for a cross-listing
Error message
Improper status #{status} for a cross-listing What it means
A defensive fallback inside add_crosslist's case statement: if status matched neither the 'active' nor 'deleted' branch, ImportError "Improper status ... for a cross-listing" is raised. With the current regex this is largely unreachable, but it guards the case-statement against future status values added without corresponding branches.
Solutions
- Keep the regex at line 55 and the case statement branches in sync when adding statuses
- Add an explicit branch (or explicit rejection) for any new status value
- Rely on the line-55 validation: ensure status is 'active' or 'deleted' before calling add_crosslist
- Remove custom patches that inject third status values
Example fix
# before
case status
when /\Aactive\z/i then ...
when /\Adeleted\z/i then ...
else raise
end
# after
unless status =~ /\A(active|deleted)\z/i
raise ImportError, "Improper status #{status.inspect} for a cross-listing"
end
case status
when /\Aactive\z/i then ...
when /\Adeleted\z/i then ...
end Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, 'status must be active or deleted' unless status.to_s.match?(/\A(active|deleted)\z/i)
Try / catch
begin
xlist.add_crosslist(xlist_course_id, section_id, status)
rescue SIS::ImportError => e
Rails.logger.warn("Crosslist rejected: #{e.message}")
end Prevention
- Keep the validation regex and case branches in sync when extending statuses
- Avoid custom patches introducing extra status values
- Cover add_crosslist with specs for each accepted status
When it happens
Trigger: A code change introduces a new accepted status in the line-55 regex (or bypasses it) but no case branch handles it; a caller monkey-patching or refactoring the validation lets an unexpected status through to the case statement.
Common situations: Custom Canvas patches/plugins extending cross-listing statuses; refactors that decouple the upfront regex validation from the case dispatch.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Improper status "# " for a cross-listing
- A cross-listing referenced a non-existent section #
- A deleted cross-listing failed: #
- A new_id, '# ', referenced an existing # and the # with #…
- A new_integration_id, '#
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/3e2f092ba367a64a.
Report an issue: GitHub.
Appendix: source
Thrown at lib/sis/xlist_importer.rb:121
rescue => e
raise ImportError, "An active cross-listing failed: #{e}"
end
when /\Adeleted\z/i
if @course && section.course_id != @course.id
@success_count += 1
return
end
begin
@course_ids_to_update_associations.merge [section.course_id, section.nonxlist_course_id]
section.uncrosslist(run_jobs_immediately: true)
rescue => e
raise ImportError, "A deleted cross-listing failed: #{e}"
end
else
raise ImportError, "Improper status #{status} for a cross-listing"
end
@success_count += 1
end
end
end
end
end
View on GitHub (pinned to 1c9f0bb801)