instructure/canvas-lms · error · InvalidDataError

Invalid

Error message

Invalid %{field}: "%{type}"

What it means

import_object dispatches on object[:object_type] and only supports 'outcome' and 'group'. Any other value (including nil or a non-string) falls to the else branch and raises this error naming the offending type. The field must be a plain lowercase string, not a symbol or capitalized variant.

Solutions

  1. Set object_type to exactly 'outcome' or 'group' (lowercase string).
  2. Default or map unknown/missing object_type before calling import_object, e.g. from a 'type' column in your source data.
  3. Validate the payload against the allowed set ['outcome','group'] before starting the import.

Example fix

// before
{ object_type: 'Objective', ... }
// after
{ object_type: 'outcome', ... }
Defensive patterns

Strategy: validation

Validate before calling

raise ArgumentError, "object_type must be outcome or group" unless %w[outcome group].include?(object[:object_type].to_s)

Type guard

def valid_object_type?(t)
  %w[outcome group].include?(t)
end

Try / catch

begin
  importer.import_object(object)
rescue Outcomes::Import::InvalidDataError => e
  errors << {row: object, reason: e.message}
end

Prevention

When it happens

Trigger: import_object with object[:object_type] == 'Outcome', 'learning_outcome_group', 'objective', or missing entirely (type is then nil and appears quoted as "" in the message). Also triggered when the value is a symbol :outcome instead of the string 'outcome'.

Common situations: Hand-written import JSON/CSV where object_type was renamed or omitted; generators that emit capitalized type names; clients mixing Canvas API terminology ('group' vs 'outcome_group') with this importer's vocabulary.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at lib/outcomes/import.rb:64

          '"%{field}" must be either "%{active}" or "%{deleted}"',
          field: "workflow_state",
          active: "active",
          deleted: "deleted"
        )
      end
    end

    def import_object(object)
      check_object(object)

      type = object[:object_type]
      case type
      when "outcome"
        import_outcome(object)
      when "group"
        import_group(object)
      else
        raise InvalidDataError, I18n.t(
          'Invalid %{field}: "%{type}"',
          field: "object_type",
          type:
        )
      end
    end

    def import_group(group)
      invalid = group.keys.select do |k|
        group[k].present? && OBJECT_ONLY_FIELDS.include?(k)
      end
      if invalid.present?
        raise InvalidDataError, I18n.t(
          "Invalid fields for a group: %{invalid}",
          invalid: invalid.map(&:to_s).inspect
        )
      end

View on GitHub (pinned to 1c9f0bb801)