{"record":{"id":"873e630b3c0bafa9","repo":"mongodb/mongoid","slug":"attempted-to-modify-the-read-only-association-n-873e63","errorCode":null,"errorMessage":"Attempted to modify the read-only association '%{name}' on '%{klass}'.","messagePattern":"Attempted to modify the read-only association '%(.+?)' on '%(.+?)'\\.","errorType":"exception","errorClass":"Mongoid::Errors::ReadonlyAssociation","httpStatus":null,"severity":"error","filePath":"lib/mongoid/association/referenced/has_many_through/proxy.rb","lineNumber":61,"sourceCode":"            @_association = association\n            @preloaded    = preloaded\n          end\n\n          def criteria\n            @criteria ||= @_association.criteria(@_base)\n          end\n\n          private\n\n          def _source\n            @preloaded || criteria\n          end\n\n          public\n\n          READONLY_METHODS.each do |meth|\n            define_method(meth) do |*|\n              raise Mongoid::Errors::ReadonlyAssociation.new(@_base.class, @_association)\n            end\n          end\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":43,"sourceCodeEnd":69,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/association/referenced/has_many_through/proxy.rb#L43-L69","documentation":"Error \"Attempted to modify the read-only association '%{name}' on '%{klass}'.\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/association/referenced/has_many_through/proxy.rb:61 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}