instructure/canvas-lms · error · GraphQL::ExecutionError

selectedDateFilter must be one of: #

Error message

selectedDateFilter must be one of: #{VALID_DATE_FILTERS.join(", ")}

What it means

The course work widget's "selectedDateFilter" must be a String in VALID_DATE_FILTERS ("not_submitted", "missing", "submitted"). validate_course_work_filters! raises this GraphQL::ExecutionError for any other value or non-string type.

Solutions

  1. Use exactly one of "not_submitted", "missing", or "submitted"
  2. Check VALID_DATE_FILTERS in app/graphql/mutations/update_widget_dashboard_config.rb for the current allowed list
  3. Sync the client-side filter enum with the server constant

Example fix

// before
filters: { "selectedDateFilter": "late" }
// after
filters: { "selectedDateFilter": "missing" }
Defensive patterns

Strategy: validation

Validate before calling

const VALID = ["not_submitted", "missing", "submitted"];
if (filters.selectedDateFilter !== undefined && !(typeof filters.selectedDateFilter === "string" && VALID.includes(filters.selectedDateFilter))) {
  throw new Error(`selectedDateFilter must be one of: ${VALID.join(", ")}`);
}

Type guard

const isDateFilter = (v) => typeof v === "string" && ["not_submitted","missing","submitted"].includes(v);

Prevention

When it happens

Trigger: Sending filters["selectedDateFilter"] = "late", "all", "NOT_SUBMITTED", an array, or null for the course work widget.

Common situations: Client enum drifted from the server allowlist; using date-range strings (e.g. "last_week") that this widget does not support; case sensitivity.

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

Appendix: source

Thrown at app/graphql/mutations/update_widget_dashboard_config.rb:137

    invalid_keys = filters.keys - ["filter"]
    unless invalid_keys.empty?
      raise GraphQL::ExecutionError, "invalid filter keys for todo list widget: #{invalid_keys.join(", ")}"
    end
  end

  def validate_course_work_filters!(filters)
    if filters.key?("selectedCourse")
      course_value = filters["selectedCourse"]
      unless course_value.is_a?(String) && (course_value == "all" || course_value.match?(/^course_\d+$/))
        raise GraphQL::ExecutionError, "selectedCourse must be 'all' or 'course_{id}'"
      end
    end

    if filters.key?("selectedDateFilter")
      date_filter = filters["selectedDateFilter"]
      unless date_filter.is_a?(String) && VALID_DATE_FILTERS.include?(date_filter)
        raise GraphQL::ExecutionError, "selectedDateFilter must be one of: #{VALID_DATE_FILTERS.join(", ")}"
      end
    end

    invalid_keys = filters.keys - ["selectedCourse", "selectedDateFilter"]
    unless invalid_keys.empty?
      raise GraphQL::ExecutionError, "invalid filter keys for course work widget: #{invalid_keys.join(", ")}"
    end
  end

  def validate_generic_filters!(filters)
    filters.each_value do |value|
      validate_filter_value!(value)
    end
  end

  def validate_filter_value!(value)
    return if value.nil?

View on GitHub (pinned to 1c9f0bb801)