instructure/canvas-lms · error · InvalidDataError

The " " field is required

Error message

The "%{field}" field is required

What it means

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.

Solutions

  1. Fill in the blank field named in the error for that row (title or vendor_guid).
  2. Generate unique vendor_guid values for rows that lack external IDs.
  3. Pre-validate all rows with a script (presence of vendor_guid/title) before running the import.

Example fix

// before
{ title: "Outcome A" } # no vendor_guid
// after
{ vendor_guid: "outcome-a-001", title: "Outcome A" }
Defensive patterns

Strategy: validation

Validate before calling

rows.each_with_index do |row, i|
  %i[vendor_guid title].each do |f|
    raise "row #{i}: #{f} is required" if row[f].blank?
  end
end

Try / catch

begin
  importer.run
rescue Outcomes::Import::InvalidDataError => e
  collect_error(e.message) # 'The "vendor_guid" field is required'
end

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/7043ed76d75c8ace. Report an issue: GitHub.

Appendix: source

Thrown at lib/outcomes/import.rb:34

# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#

module Outcomes
  module Import
    class InvalidDataError < RuntimeError; end

    class DataFormatError < RuntimeError; end

    GROUP_ONLY_FIELDS = %i[course_id].freeze
    OBJECT_ONLY_FIELDS = %i[calculation_method calculation_int ratings].freeze
    VALID_WORKFLOWS = [nil, "", "active", "deleted"].freeze

    def check_object(object)
      %i[vendor_guid title].each do |field|
        next if object[field].present?

        raise InvalidDataError, I18n.t(
          'The "%{field}" field is required', field:
        )
      end
      if object[:vendor_guid].match?(/\s/)
        raise InvalidDataError, I18n.t(
          'The "%{field}" field must have no spaces',
          field: "vendor_guid"
        )
      end
      unless VALID_WORKFLOWS.include? object[:workflow_state]
        raise InvalidDataError, I18n.t(
          '"%{field}" must be either "%{active}" or "%{deleted}"',
          field: "workflow_state",
          active: "active",
          deleted: "deleted"
        )
      end
    end

View on GitHub (pinned to 1c9f0bb801)