instructure/canvas-lms · error

invalid description value: #

Error message

invalid description value: #{rating[:description]}

What it means

OutcomesAcademicBenchmarkImportApiController#parse_rating checks that each rating has a non-nil String :description and raises otherwise. The description names the mastery level and is required for every rating in the array.

Solutions

  1. Include a string description on every rating object.
  2. Map alternate keys (e.g. 'label') to description before sending.
  3. Coerce numeric labels to strings only if that is the intent; otherwise supply real text.
  4. Validate presence and type of description client-side.

Example fix

// before
ratings: [{ points: 3 }]
// after
ratings: [{ description: "Mastery", points: 3 }]
Defensive patterns

Strategy: validation

Validate before calling

raise ArgumentError unless ratings.all? { |r| r[:description].is_a?(String) && !r[:description].empty? }

Type guard

def described_rating?(r) = r[:description].is_a?(String) && !r[:description].nil?

Try / catch

begin
  import_outcomes(options)
rescue RuntimeError => e
  raise InvalidRatingDescription, e.message if e.message.start_with?('invalid description value:')
  raise
end

Prevention

When it happens

Trigger: A ratings entry missing :description, having nil description, or a non-string description (number, hash) — e.g. { points: 3 } or { description: 5, points: 3 }.

Common situations: Forms that send the rating label under a different key (name/label instead of description); JSON where description was dropped by a serializer; clients sending numeric level indexes instead of text.

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/25910b5725af846c. Report an issue: GitHub.

Appendix: source

Thrown at app/controllers/outcomes_academic_benchmark_import_api_controller.rb:140

    value
  end

  def parse_calculation_int(calc_method, value)
    int = value.nil? ? nil : parse_int(value)
    unless LearningOutcome.valid_calculation_int?(int, calc_method)
      raise "invalid calculation_int: #{value}"
    end

    int
  end

  def parse_rating(rating)
    if rating.nil? || !rating.is_a?(ActionController::Parameters)
      raise "invalid ratings value: #{rating}"
    end
    if rating[:description].nil? || !rating[:description].is_a?(String)
      raise "invalid description value: #{rating[:description]}"
    end

    { description: rating[:description], points: parse_int(rating[:points]) }
  end
end

View on GitHub (pinned to 1c9f0bb801)