instructure/canvas-lms · error · Checkpoints::SetTypeRequiredError

set_type is required, but was not provided

Error message

set_type is required, but was not provided

What it means

Checkpoints::DateOverrideCommonService#call iterates @overrides and determines each override's set_type (e.g. CourseSection, ADHOC, Group). It reads set_type from the override hash, or looks it up from the existing AssignmentOverride when an :id is present; if neither source yields a set_type it raises SetTypeRequiredError. set_type is mandatory to select the right downstream service (services.fetch(set_type)).

Solutions

  1. Include set_type: 'ADHOC'|'CourseSection'|'Group' (matching AssignmentOverride.set_type values) in each override hash.
  2. If updating an existing override, pass its correct :id so the service can read set_type from the DB.
  3. Validate the overrides payload in the controller before invoking the service.

Example fix

// before
overrides: [{ due_at: date }]
// after
overrides: [{ due_at: date, set_type: 'ADHOC' }]
Defensive patterns

Strategy: validation

Validate before calling

overrides.each do |o|
  raise ArgumentError, 'set_type or id required' if o[:set_type].blank? && o[:id].blank?
end

Type guard

def set_type_resolvable?(override)
  !override[:set_type].nil? || !override[:id].nil?
end

Try / catch

begin
  Checkpoints::DateOverrideCommonService.call(checkpoint:, overrides:)
rescue Checkpoints::SetTypeRequiredError => e
  render json: { error: e.message }, status: :bad_request
end

Prevention

When it happens

Trigger: Calling call(checkpoint:, overrides:[...]) where an override hash has no :set_type and no :id, or has an :id that does not belong to @checkpoint.assignment_overrides (find raises) is different — this error fires specifically when set_type stays nil after both lookups, e.g. override: {} or override: {id: nil}.

Common situations: API consumers posting date overrides for discussion checkpoints without the set_type field; clients updating an existing override but passing the id under a different key so the lookup misses; hand-built hashes in specs/console omitting set_type.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at app/services/checkpoints/date_override_common_service.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/>.

class Checkpoints::DateOverrideCommonService < ApplicationService
  def initialize(checkpoint:, overrides:)
    super()
    @checkpoint = checkpoint
    @overrides = overrides
  end

  def call
    @overrides.each do |override|
      set_type = override.fetch(:set_type, nil)

      # If set_type is nil and override has an id, fetch the set_type from the checkpoint
      set_type = @checkpoint.assignment_overrides.find(override[:id]).set_type if set_type.nil? && override[:id]

      raise Checkpoints::SetTypeRequiredError, "set_type is required, but was not provided" if set_type.nil?

      service = services.fetch(set_type) { |key| raise Checkpoints::SetTypeNotSupportedError, "set_type of '#{key}' not supported. Supported types: #{services.keys}" }
      service.call(checkpoint: @checkpoint, override:)
    end
  end

  private

  def services
    {}
  end
end

View on GitHub (pinned to 1c9f0bb801)