Gitlab::Diff::Position is redefined on hot reload, causing its definition in yaml_column_permitted_classes to be out-of-date
Trying to post a note on a commit diff after your GDK has hot-reloaded its code once results in an error on the POST to /(wherever)/notes?html=true — traceback at the end of the description.
The root cause is that the class gets redefined on hot-reload (creating a Gitlab::Diff::Position with a new object_id etc.), but we don't re-run after_initialize hooks on the config, meaning config.active_record.yaml_column_permitted_classes still has a reference to the Gitlab::Diff::Position class as it was created on first load. Attempts to serialise objects created with the reloaded class fail.
It's not clear to me what a good fix for this would look like — presumably it affects other classes in this list that are also subject to this kind of reload, but I haven't read very deeply into our config so maybe there aren't any.
Psych::DisallowedClass in Projects::NotesController#create
Tried to dump unspecified class: Gitlab::Diff::Position
Extracted source (around line #568):
#566
#567 unless Symbol === target || @permitted_classes[target.class]
*568 [" ", "raise", " DisallowedClass.new('dump', target.class.name || target.class.inspect)\n"]#569 end
#570
#571 super
Extracted source (around line #114):
#112
#113 @emitter.start_document version, [], false
*114 [" ", "accept", " object\n"]#115 @emitter.end_document !@emitter.streaming?
#116 end
#117 alias :<< :push
Extracted source (around line #603):
#601
#602 visitor = Psych::Visitors::RestrictedYAMLTree.create options
*603 [" visitor ", "<<", " o\n"]#604 visitor.tree.yaml io, options
#605 end
#606
Rails.root: /Volumes/g/gdk/gitlab
Application Trace
psych (5.2.3) lib/psych/visitors/yaml_tree.rb:568:in `accept'
psych (5.2.3) lib/psych/visitors/yaml_tree.rb:114:in `push'
psych (5.2.3) lib/psych.rb:603:in `safe_dump'
activerecord (7.2.3) lib/active_record/coders/yaml_column.rb:19:in `dump'
activerecord (7.2.3) lib/active_record/coders/column_serializer.rb:26:in `dump'
activerecord (7.2.3) lib/active_record/type/serialized.rb:29:in `serialize'
activemodel (7.2.3) lib/active_model/type/helpers/mutable.rb:8:in `cast'
activemodel (7.2.3) lib/active_model/attribute.rb:199:in `type_cast'
activemodel (7.2.3) lib/active_model/attribute.rb:43:in `value'
activemodel (7.2.3) lib/active_model/attribute_set.rb:51:in `fetch_value'
activerecord (7.2.3) lib/active_record/attribute_methods/read.rb:39:in `_read_attribute'
activemodel (7.2.3) lib/active_model/attribute_methods.rb:273:in `position'
app/models/concerns/diff_positionable_note.rb:71:in `set_original_position'
activesupport (7.2.3) lib/active_support/callbacks.rb:362:in `block in make_lambda'
activesupport (7.2.3) lib/active_support/callbacks.rb:179:in `block in call'
activesupport (7.2.3) lib/active_support/callbacks.rb:669:in `block (2 levels) in default_terminator'
activesupport (7.2.3) lib/active_support/callbacks.rb:668:in `catch'
activesupport (7.2.3) lib/active_support/callbacks.rb:668:in `block in default_terminator'
activesupport (7.2.3) lib/active_support/callbacks.rb:180:in `call'
activesupport (7.2.3) lib/active_support/callbacks.rb:560:in `block in invoke_before'
activesupport (7.2.3) lib/active_support/callbacks.rb:560:in `each'
activesupport (7.2.3) lib/active_support/callbacks.rb:560:in `invoke_before'
activesupport (7.2.3) lib/active_support/callbacks.rb:109:in `run_callbacks'
activesupport (7.2.3) lib/active_support/callbacks.rb:914:in `_run_validation_callbacks'
activemodel (7.2.3) lib/active_model/validations/callbacks.rb:115:in `run_validations!'
activemodel (7.2.3) lib/active_model/validations.rb:368:in `valid?'
activerecord (7.2.3) lib/active_record/validations.rb:71:in `valid?'
app/services/notes/create_service.rb:17:in `block in execute'
lib/gitlab/gitaly_client.rb:470:in `allow_n_plus_1_calls'
app/services/notes/create_service.rb:14:in `execute'
app/controllers/concerns/notes_actions.rb:41:in `create'