{"record":{"id":"1724ce59cdac6801","repo":"instructure/canvas-lms","slug":"cannot-find-params-context-type-context-for-id-params","errorCode":null,"errorMessage":"Cannot find #{params[:context_type] || \"Context\"} for ID: #{params[:context_id]}","messagePattern":"Cannot find #(.+?) for ID: #(.+?)","errorType":"exception","errorClass":"ActiveRecord::RecordNotFound","httpStatus":404,"severity":"error","filePath":"app/controllers/application_controller.rb","lineNumber":1455,"sourceCode":"        flash[:warning] = flash_message\n        redirect_back_or_to root_url\n      end\n    end\n    set_no_cache_headers\n  end\n\n  # To be used as a before_action, requires controller or controller actions\n  # to have their urls scoped to a context in order to be valid.\n  # So /courses/5/assignments or groups/1/assignments would be valid, but\n  # not /assignments\n  def require_context(user_scope: nil)\n    get_context(user_scope:)\n    unless @context\n      if @context_is_current_user\n        store_location\n        redirect_to login_url\n      elsif params[:context_id]\n        raise ActiveRecord::RecordNotFound, \"Cannot find #{params[:context_type] || \"Context\"} for ID: #{params[:context_id]}\"\n      else\n        raise ActiveRecord::RecordNotFound, \"Context is required, but none found\"\n      end\n    end\n    !@context.nil?\n  end\n\n  def require_context_and_read_access\n    require_context && authorized_action(@context, @current_user, :read)\n  end\n\n  helper_method :clean_return_to\n\n  def require_account_context\n    require_context_type(Account)\n  end\n\n  def require_course_context","sourceCodeStart":1437,"sourceCodeEnd":1473,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/controllers/application_controller.rb#L1437-L1473","documentation":"process_user_observer in lib/sis/user_observer_importer.rb raises this ImportError when the observer_id argument passed in is blank (nil, empty, or whitespace). An observer-less user_observer row cannot be resolved to a pseudonym via `@root_account.pseudonyms.active.find_by(sis_user_id: observer_id)`, so the import aborts that row. It is a required-argument guard executed before any database lookup.","triggerScenarios":"Calling SIS::UserObserverImporter#process_user_observer with observer_id nil/empty — e.g. a CSV users_observers row missing the observer_id column, or programmatic callers passing an empty string for observer_id while student_id is set.","commonSituations":"Malformed SIS CSV exports where the observer_id header exists but cells are empty; an integration script that skips optional-looking columns; template files where the observer column was accidentally left blank for some rows.","solutions":["Fix the source data so every user_observer row has a non-blank observer_id (the observer's SIS ID).","Skip or fix blank rows in the pre-import pipeline instead of feeding them to the importer.","If observer_id is legitimately unknown, remove the row rather than passing an empty string."],"exampleFix":"// before (CSV row)\nuser_id,observer_id\nSTU001,\n\n// after\nuser_id,observer_id\nSTU001,OBS009","handlingStrategy":"validation","validationCode":"raise 'observer_id required' if observer_id.nil? || observer_id.to_s.strip.empty?","typeGuard":"def blank?(v) = v.nil? || v.to_s.strip.empty?","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":["Validate required CSV columns before starting the SIS import.","Trim and sanitize all identifier fields in pre-processing.","Fail fast on blank required cells instead of passing rows through."],"tags":["sis-import","ruby","missing-argument","user-observer"],"backgroundTag":"missing-required-argument","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"}