instructure/canvas-lms · warning

[Accessibility::CategoryBreakdownService] dropping unknown…

Error message

[Accessibility::CategoryBreakdownService] dropping unknown rule_type=#{rule_type} count=#{count}

What it means

Accessibility::CategoryBreakdownService#call aggregates accessibility issue counts per course grouped by rule_type, mapping each rule_type to a category via Accessibility::Rule.category_for. When a rule_type stored in the DB has no registered category (unknown/unregistered rule), it logs this warning and drops that row from the breakdown instead of crashing.

Solutions

  1. Backfill/rename stale rule_type values in accessibility scan data to match Accessibility::Rule's current registry
  2. Re-run accessibility scans so issues are stored with valid current rule_types
  3. Register the missing rule in Accessibility::Rule (add a category mapping) if the rule should still exist
  4. Check whether a plugin registering custom accessibility rules is disabled in this environment

Example fix

// before
category = Accessibility::Rule.category_for(rule_type)
if category.nil?
  Rails.logger.warn("[Accessibility::CategoryBreakdownService] dropping unknown rule_type=#{rule_type} count=#{count}")
  next
end

// after: migrate stale data
# data fix:
AccessibilityIssue.where(rule_type: 'old_rule_name').update_all(rule_type: 'new_rule_name')
Defensive patterns

Strategy: fallback

Validate before calling

unless Accessibility::Rule.category_for(rule_type)
  Rails.logger.warn("unknown rule_type #{rule_type}; migrating data needed")
end

Type guard

def known_rule_type?(rule_type)
  !Accessibility::Rule.category_for(rule_type).nil?
end

Prevention

When it happens

Trigger: The accessibility_cOURSE_workflow_states/issue data contains a rule_type that Accessibility::Rule.category_for doesn't recognize — typically after a rule was renamed/removed in code while old scanned rows persist, or a plugin-added rule is no longer loaded.

Common situations: Migrations renaming accessibility rules without backfilling existing scan rows; downgrading Canvas so new rule_types in the DB are unknown to the running code; disabled plugins that previously registered custom rules.

Related errors


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

Appendix: source

Thrown at app/services/accessibility/category_breakdown_service.rb:47

  def initialize(course_ids:)
    @course_ids = course_ids
  end

  # @return [Hash] { course_id => { category => { workflow_state => count } } }
  # Unknown rule_types are dropped.
  def call
    return {} if @course_ids.blank?

    rows = AccessibilityIssue
           .where(course_id: @course_ids)
           .group(:course_id, :rule_type, :workflow_state)
           .count

    result = {}
    rows.each do |(course_id, rule_type, workflow_state), count|
      category = Accessibility::Rule.category_for(rule_type)
      if category.nil?
        Rails.logger.warn(
          "[Accessibility::CategoryBreakdownService] dropping unknown rule_type=#{rule_type} count=#{count}"
        )
        next
      end

      result[course_id] ||= {}
      result[course_id][category] ||= {}
      result[course_id][category][workflow_state.to_sym] =
        (result[course_id][category][workflow_state.to_sym] || 0) + count
    end

    result
  end
end

View on GitHub (pinned to 1c9f0bb801)