instructure/canvas-lms · error · CanvasOperations::Errors::InvalidPropertyValue

progress_tracking must be a boolean

Error message

progress_tracking must be a boolean

What it means

CanvasOperations::Errors::InvalidPropertyValue raised by the progress_tracking= setter on operations with the ProgressTracking concern. The class-level progress_tracking flag controls whether a Progress record is automatically created and updated; only literal true or false are accepted to avoid truthy/falsy confusion.

Solutions

  1. Pass a real boolean: self.progress_tracking = true (or false)
  2. Coerce string config values with e.g. value == 'true' or ActiveModel::Type::Boolean.new.cast(value)
  3. Remove the assignment to fall back to the default instead of assigning nil

Example fix

// before
self.progress_tracking = ENV['PROGRESS_TRACKING']
// after
self.progress_tracking = ENV['PROGRESS_TRACKING'] == 'true'
Defensive patterns

Strategy: validation

Validate before calling

value = ActiveModel::Type::Boolean.new.cast(ENV['PROGRESS_TRACKING'])
raise 'must be boolean' unless [true, false].include?(value)

Try / catch

rescue CanvasOperations::Errors::InvalidPropertyValue
  self.progress_tracking = false
end

Prevention

When it happens

Trigger: Assigning a truthy-but-non-boolean value such as progress_tracking = 'true', 1, or nil at the class level of an operation.

Common situations: Reading the flag from ENV/config without converting it ('true'/'false' strings); YAML or JSON config that yields 1/0 or nil; copy-pasting boolean settings without coercion.

Related errors


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

Appendix: source

Thrown at lib/canvas_operations/base_concerns/progress_tracking.rb:44

      #
      # @return [Boolean] true if progress tracking is enabled, false otherwise
      def progress_tracking
        return @progress_tracking if instance_variable_defined?(:@progress_tracking)

        superclass.respond_to?(:progress_tracking) ? superclass.progress_tracking : false
      end

      # Enable or disable progress tracking for this operation.
      #
      # When enabled, a Progress object will be attached to the `context`
      # to track progress of the operation.
      #
      # Operations are responsible for incrementing progress, but `BaseOperation`
      # will automatically set the Progress state to completed or failed as appropriate.
      #
      # @param value [Boolean] true to enable progress tracking, false to disable
      def progress_tracking=(value)
        raise CanvasOperations::Errors::InvalidPropertyValue, "progress_tracking must be a boolean" unless [true, false].include?(value)

        @progress_tracking = value
      end

      # Convenience instance methods for accessing the class-level progress_tracking property.
      def self.extended(base)
        base.class_eval do
          protected

          def progress_tracking?
            self.class.progress_tracking
          end
        end
      end
    end
  end
end

View on GitHub (pinned to 1c9f0bb801)