{"record":{"id":"fa697c7c947fe622","repo":"instructure/canvas-lms","slug":"field-must-be-either-active-or-deleted","errorCode":null,"errorMessage":"\"%{field}\" must be either \"%{active}\" or \"%{deleted}\"","messagePattern":"\"%(.+?)\" must be either \"%(.+?)\" or \"%(.+?)\"","errorType":"validation","errorClass":"InvalidDataError","httpStatus":null,"severity":"error","filePath":"lib/outcomes/import.rb","lineNumber":45,"sourceCode":"    OBJECT_ONLY_FIELDS = %i[calculation_method calculation_int ratings].freeze\n    VALID_WORKFLOWS = [nil, \"\", \"active\", \"deleted\"].freeze\n\n    def check_object(object)\n      %i[vendor_guid title].each do |field|\n        next if object[field].present?\n\n        raise InvalidDataError, I18n.t(\n          'The \"%{field}\" field is required', field:\n        )\n      end\n      if object[:vendor_guid].match?(/\\s/)\n        raise InvalidDataError, I18n.t(\n          'The \"%{field}\" field must have no spaces',\n          field: \"vendor_guid\"\n        )\n      end\n      unless VALID_WORKFLOWS.include? object[:workflow_state]\n        raise InvalidDataError, I18n.t(\n          '\"%{field}\" must be either \"%{active}\" or \"%{deleted}\"',\n          field: \"workflow_state\",\n          active: \"active\",\n          deleted: \"deleted\"\n        )\n      end\n    end\n\n    def import_object(object)\n      check_object(object)\n\n      type = object[:object_type]\n      case type\n      when \"outcome\"\n        import_outcome(object)\n      when \"group\"\n        import_group(object)\n      else","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/outcomes/import.rb#L27-L63","documentation":"Outcomes::Import validates every imported object via check_object, which requires workflow_state (if given) to be one of the VALID_WORKFLOWS: nil, empty string, 'active', or 'deleted'. This error is raised for any other value. It exists because the import assigns workflow_state directly to LearningOutcome/LearningOutcomeGroup models and only understands these two states.","triggerScenarios":"Calling import_object (or check_object) with object[:workflow_state] set to something like 'Active', 'inactive', 'published', or a localized/translated string; whitespace-only or trailing-space values like 'active ' also fail since VALID_WORKFLOWS only has exact matches.","commonSituations":"CSV/API payloads authored by hand where someone writes 'Active' (wrong case) or 'archived'; clients reusing account-level workflow states ('available', 'created') that are valid elsewhere in Canvas but not here; whitespace accidentally introduced by spreadsheet exports.","solutions":["Set workflow_state to exactly 'active' or 'deleted' (case-sensitive, no surrounding spaces).","Omit workflow_state or set it to nil/empty string to default to 'active' (import_group sets it via .presence).","Strip and downcase the value before passing it into the import, then reject anything not in %w[active deleted]."],"exampleFix":"// before\n{ object_type: 'outcome', workflow_state: 'Active' }\n// after\n{ object_type: 'outcome', workflow_state: 'active' }","handlingStrategy":"validation","validationCode":"ALLOWED = %w[active deleted].freeze\nws = object[:workflow_state]\nraise ArgumentError, \"bad workflow_state\" if ws.present? && !ALLOWED.include?(ws.to_s.strip)","typeGuard":"def valid_workflow_state?(ws)\n  ws.blank? || %w[active deleted].include?(ws)\nend","tryCatchPattern":"begin\n  importer.import_object(object)\nrescue Outcomes::Import::InvalidDataError => e\n  Rails.logger.warn(\"skipped row: #{e.message}\")\nend","preventionTips":["Normalize case and trim whitespace on workflow_state before import","Omit the field entirely when unsure — it defaults to active","Validate whole files against the expected schema before importing"],"tags":["validation","enum","outcomes-import","ruby"],"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"}