{"record":{"id":"7043ed76d75c8ace","repo":"instructure/canvas-lms","slug":"the-field-field-is-required","errorCode":null,"errorMessage":"The \"%{field}\" field is required","messagePattern":"The \"%(.+?)\" field is required","errorType":"validation","errorClass":"InvalidDataError","httpStatus":null,"severity":"error","filePath":"lib/outcomes/import.rb","lineNumber":34,"sourceCode":"# You should have received a copy of the GNU Affero General Public License along\n# with this program. If not, see <http://www.gnu.org/licenses/>.\n#\n\nmodule Outcomes\n  module Import\n    class InvalidDataError < RuntimeError; end\n\n    class DataFormatError < RuntimeError; end\n\n    GROUP_ONLY_FIELDS = %i[course_id].freeze\n    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","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/outcomes/import.rb#L16-L52","documentation":"Raised by Outcomes::Import#check_object when a required field (vendor_guid or title) is missing or blank on an outcome object being imported. Every outcome must carry an external identifier (vendor_guid) and a title; the importer raises InvalidDataError naming the offending field. This is the row-level contract enforcement before persistence.","triggerScenarios":"CSV row with empty title cell; row with empty vendor_guid cell; headers valid but a data row simply missing those columns' values; programmatically built objects passed to import_object without :vendor_guid or :title.","commonSituations":"Spreadsheet rows where authors left the title or external ID blank; bulk exports from other systems that don't guarantee an external identifier; partially filled templates.","solutions":["Fill in the blank field named in the error for that row (title or vendor_guid).","Generate unique vendor_guid values for rows that lack external IDs.","Pre-validate all rows with a script (presence of vendor_guid/title) before running the import."],"exampleFix":"// before\n{ title: \"Outcome A\" } # no vendor_guid\n// after\n{ vendor_guid: \"outcome-a-001\", title: \"Outcome A\" }","handlingStrategy":"validation","validationCode":"rows.each_with_index do |row, i|\n  %i[vendor_guid title].each do |f|\n    raise \"row #{i}: #{f} is required\" if row[f].blank?\n  end\nend","typeGuard":null,"tryCatchPattern":"begin\n  importer.run\nrescue Outcomes::Import::InvalidDataError => e\n  collect_error(e.message) # 'The \"vendor_guid\" field is required'\nend","preventionTips":["Require title and vendor_guid in your spreadsheet template","Reject blank cells in those columns at data-entry time","Generate vendor_guids automatically when source data lacks them"],"tags":["csv","required-field","validation","outcomes"],"backgroundTag":"empty-required-field","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"}