instructure/canvas-lms · error · ArgumentError
missing required attributes: #
Error message
missing required attributes: #{missing.to_a} What it means
attr_config_validate runs after defaults are applied and asserts that every attribute declared known in the attr_config was supplied (or defaulted). If any known attribute has neither a value nor a default, ArgumentError lists the missing keys. It enforces that stream/index definitions are complete before use.
Solutions
- Supply values for every attribute named in `missing required attributes:`
- Add defaults via attr_config declarations so validation passes
- Remove attributes from the attr_config declaration if they are no longer needed
- Check recent changes to the stream/index class for newly required attributes
Example fix
// before EventStream::Stream.new(aggregate: ...) // after EventStream::Stream.new(aggregate: ..., record: ..., attribute_data: ...)
Defensive patterns
Strategy: validation
Validate before calling
missing = klass.attr_config_known - (given.keys | klass.attr_config_defaults.keys)
raise "missing: #{missing}" unless missing.empty? Try / catch
begin
stream = EventStream::Stream.new(**attrs)
rescue ArgumentError => e
raise unless e.message.start_with?('missing required attributes')
Rails.logger.error("Incomplete stream config: #{e.message}")
end Prevention
- Declare defaults for every attr_config attribute
- Centralize stream instantiation in one factory
- Add specs that instantiate every stream class with defaults
When it happens
Trigger: Instantiating an EventStream::Stream or Index whose class defines an attr_config attribute but neither passes a value for it at construction nor provides a default; calling attr_config_validate manually with a partially populated config.
Common situations: Forgetting a required field in a custom event stream definition; renaming an attribute in one place but not at all construction sites; a nil-vs-absent confusion where the key was never set at all.
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
- An institutional tag category did not pass validation
- app '# ' must be one of: #
- cannot change column: captions - locked by Master Course
- Cannot validate existence for resource type: #
- Caption cannot be empty.
AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15).
Data as JSON: /api/errors/9f77cc00b2cd25df.
Report an issue: GitHub.
Appendix: source
Thrown at gems/event_stream/lib/event_stream/attr_config.rb:92
value = typecast.call(name, value)
end
attr_config_values[name] = value
end
end
end
def attr_config_values
@attr_config_values ||= {}
end
def attr_config_validate
self.class.attr_config_defaults.each do |key, value|
unless attr_config_values.key?(key)
attr_config_values[key] = value
end
end
missing = self.class.attr_config_known - attr_config_values.keys
raise ArgumentError, "missing required attributes: #{missing.to_a}" unless missing.empty?
end
def self.included(base)
base.extend(ClassMethods)
end
end
View on GitHub (pinned to 1c9f0bb801)