{"record":{"id":"7c4dd6f25b1429be","repo":"instructure/canvas-lms","slug":"no-account-found-for-context","errorCode":null,"errorMessage":"No account found for context","messagePattern":"No account found for context","errorType":"exception","errorClass":"ActiveRecord::RecordNotFound","httpStatus":404,"severity":"error","filePath":"app/controllers/application_controller.rb","lineNumber":3171,"sourceCode":"  end\n\n  def resolve_context_account(allow_user_root_account: false)\n    case @context\n    when Account\n      @context\n    when Course, Group\n      @context.account\n    when User\n      if allow_user_root_account\n        @context.account.root_account\n      else\n        raise \"Account can't be derived from a User context\"\n      end\n    when CourseSection\n      @context.course.account\n    else\n      account = @context.try(:account)\n      raise ActiveRecord::RecordNotFound, \"No account found for context\" unless account.present?\n\n      account\n    end\n  end\n\n  private :resolve_context_account\n\n  def set_site_admin_context\n    @context = Account.site_admin\n    add_crumb t(\"#crumbs.site_admin\", \"Site Admin\"), url_for(Account.site_admin)\n  end\n\n  def flash_notices\n    @notices ||= begin\n      notices = []\n      if !browser_supported? && !@embedded_view && !cookies[\"unsupported_browser_dismissed\"]\n        notices << { type: \"warning\", content: { html: unsupported_browser }, classes: \"unsupported_browser\" }\n      end","sourceCodeStart":3153,"sourceCodeEnd":3189,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/controllers/application_controller.rb#L3153-L3189","documentation":"process_user_observer raises this ImportError unless the status argument matches /\\A(active|deleted)\\z/i. Status is an enum of exactly 'active' or 'deleted' (case-insensitive); any other value — including 'completed', 'inactive', 'Active ', or nil — is rejected before processing.","triggerScenarios":"Calling process_user_observer with status = 'inactive', 'enrolled', empty string, or a value with stray whitespace/trailing characters so the strict \\A...\\z regex fails.","commonSituations":"CSV exports from other LMS/SIS systems using different status vocabularies; hand-edited rows with typos like 'actve'; scripts passing symbols or objects that interpolate into unexpected strings.","solutions":["Change status to exactly 'active' or 'deleted' (any casing).","Map your source system's status vocabulary to Canvas's active/deleted enum before import.","Strip whitespace and trim the status column in pre-processing.","If a valid source status has no Canvas equivalent, decide explicitly to skip the row."],"exampleFix":"// before\nprocess_user_observer('OBS009', 'STU001', 'inactive')\n\n// after\nprocess_user_observer('OBS009', 'STU001', 'deleted')","handlingStrategy":"validation","validationCode":"raise 'status must be active or deleted' unless %w[active deleted].include?(status.to_s.downcase)","typeGuard":"def valid_status?(s) = /\\A(active|deleted)\\z/i.match?(s.to_s)","tryCatchPattern":"begin\n  importer.process_user_observer(obs_id, stu_id, status)\nrescue SIS::Import::ImportError => e\n  logger.warn(\"skipped row: #{e.message}\")\nend","preventionTips":["Normalize source-system status values to Canvas's active/deleted enum before import.","Trim whitespace and downcase status columns in ETL.","Enumerate allowed statuses explicitly rather than passing raw source values."],"tags":["sis-import","ruby","invalid-enum","user-observer"],"backgroundTag":"invalid-enum-value","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}