{"record":{"id":"98e15dcbd196cb2f","repo":"instructure/canvas-lms","slug":"set-type-of-key-not-supported-supported-types-services-keys","errorCode":null,"errorMessage":"set_type of '#{key}' not supported. Supported types: #{services.keys}","messagePattern":"set_type of '#(.+?)' not supported\\. Supported types: #(.+?)","errorType":"validation","errorClass":"Checkpoints::SetTypeNotSupportedError","httpStatus":null,"severity":"error","filePath":"app/services/checkpoints/date_override_common_service.rb","lineNumber":36,"sourceCode":"# with this program. If not, see <http://www.gnu.org/licenses/>.\n\nclass Checkpoints::DateOverrideCommonService < ApplicationService\n  def initialize(checkpoint:, overrides:)\n    super()\n    @checkpoint = checkpoint\n    @overrides = overrides\n  end\n\n  def call\n    @overrides.each do |override|\n      set_type = override.fetch(:set_type, nil)\n\n      # If set_type is nil and override has an id, fetch the set_type from the checkpoint\n      set_type = @checkpoint.assignment_overrides.find(override[:id]).set_type if set_type.nil? && override[:id]\n\n      raise Checkpoints::SetTypeRequiredError, \"set_type is required, but was not provided\" if set_type.nil?\n\n      service = services.fetch(set_type) { |key| raise Checkpoints::SetTypeNotSupportedError, \"set_type of '#{key}' not supported. Supported types: #{services.keys}\" }\n      service.call(checkpoint: @checkpoint, override:)\n    end\n  end\n\n  private\n\n  def services\n    {}\n  end\nend\n","sourceCodeStart":18,"sourceCodeEnd":47,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/app/services/checkpoints/date_override_common_service.rb#L18-L47","documentation":"After resolving set_type, DateOverrideCommonService selects the handler via services.fetch(set_type); when the requested set_type is not a registered key it raises SetTypeNotSupportedError, embedding the bad key and the list of supported types. This guards against dispatching date-override handling to a service class that doesn't exist for that override kind.","triggerScenarios":"Passing an override whose set_type is not one of the registered keys in `services` (e.g. a typo like 'adhoc' lowercase, or an unsupported type such as 'Noop'/'Group' if unregistered). Fired per-override inside the loop.","commonSituations":"Typo/case mismatch in set_type strings ('adhoc' vs 'ADHOC'); new AssignmentOverride set types introduced in Canvas but not registered in this service's services map; API clients sending arbitrary strings for set_type.","solutions":["Use one of the supported set_type values exactly as listed in the error message (keys of services).","If a new legitimate set type must be supported, register its service in the `services` hash of Checkpoints::DateOverrideCommonService.","Normalize/validate set_type (upcasing, whitelist check) at the API boundary before calling the service."],"exampleFix":"// before\noverrides: [{ set_type: 'adhoc', ... }]\n// after\noverrides: [{ set_type: 'ADHOC', ... }]","handlingStrategy":"validation","validationCode":"supported = Checkpoints::DateOverrideCommonService.new(checkpoint:).send(:services).keys\nraise ArgumentError, \"bad set_type #{t}\" unless supported.include?(t)","typeGuard":"VALID_SET_TYPES = %w[ADHOC CourseSection Group].freeze\ndef supported_set_type?(t)\n  VALID_SET_TYPES.include?(t.to_s)\nend","tryCatchPattern":"begin\n  service.call(checkpoint:, overrides:)\nrescue Checkpoints::SetTypeNotSupportedError => e\n  Rails.logger.error(e.message)\n  render json: { error: e.message }, status: :unprocessable_entity\nend","preventionTips":["Use the exact set_type constants from AssignmentOverride (e.g. 'ADHOC'), never ad-hoc strings","Keep client enums in sync with the services hash","Whitelist set_type values at the API boundary"],"tags":["ruby","canvas","validation","unsupported-type"],"backgroundTag":"unsupported-enum-value","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}