instructure/canvas-lms · error · ArgumentError
PartitionManager can only work on models that are…
Error message
PartitionManager can only work on models that are Partitioned. See CanvasPartman::Concerns::Partitioned.
What it means
CanvasPartman::PartitionManager.create builds a strategy object (Dynamic or Static) to manage partitions of a model. It only accepts model classes that include CanvasPartman::Concerns::Partitioned, because the manager relies on partitioning_strategy and related APIs. Passing a plain ActiveRecord class raises ArgumentError.
Solutions
- Add `include CanvasPartman::Concerns::Partitioned` to the model class
- Verify you are passing the model class itself, not an instance or unrelated class
- Ensure the model's migration creates the partitioned table matching its strategy
Example fix
// before class QueuedMessage < ActiveRecord::Base; end PartitionManager.create(QueuedMessage) // after class QueuedMessage < ActiveRecord::Base include CanvasPartman::Concerns::Partitioned end PartitionManager.create(QueuedMessage)
Defensive patterns
Strategy: type-guard
Validate before calling
raise ArgumentError unless MyModel.include?(CanvasPartman::Concerns::Partitioned)
Type guard
def partitioned_model?(klass) = klass.is_a?(Class) && klass < CanvasPartman::Concerns::Partitioned
Prevention
- Include CanvasPartman::Concerns::Partitioned in every partitioned model
- Centralize PartitionManager usage in helpers that assert the mixin first
- Check model class definitions when adding new partitioned tables
When it happens
Trigger: Calling CanvasPartman::PartitionManager.create(SomeModel) where SomeModel does not `include CanvasPartman::Concerns::Partitioned` (or the mixin is included after the call).
Common situations: Forgetting the `include CanvasPartman::Concerns::Partitioned` line when adding a new partitioned table; using the manager against a shared base class; copy-pasting PartitionManager usage from another model.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Partition resolution failure!!! Expected "#
- An institutional tag category did not pass validation
- conversation_ids needs to be scoped to a user
- Course not found
- Do not look up MediaObjects by media_id - use the scope…
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/be700edf538573d0.
Report an issue: GitHub.
Appendix: source
Thrown at gems/canvas_partman/lib/canvas_partman/partition_manager.rb:29
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# 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/>.
require "canvas_partman/partition_manager/by_date"
require "canvas_partman/partition_manager/by_id"
require "active_record/pg_extensions"
module CanvasPartman
class PartitionManager
class << self
def create(base_class)
unless base_class < Concerns::Partitioned
raise ArgumentError, <<~TEXT
PartitionManager can only work on models that are Partitioned.
See CanvasPartman::Concerns::Partitioned.
TEXT
end
const_get(base_class.partitioning_strategy.to_s.classify).new(base_class)
end
end
attr_reader :base_class
# Create partitions to hold existing data in a non-partitioned
# table, and n future partitions
#
# @param [Integer] advance
# The number of partitions to create in advance
def create_initial_partitions(_advance = 1)
raise NotImplementedErrorView on GitHub (pinned to 1c9f0bb801)