Replies: 5 comments 1 reply
-
Hi @drsharp, thanks for reporting this issue. As you've indicated this only happens intermittently and is hard to trace we'll keep this discussion opened for the time being in the event others can share a similar experience that may allow us to troubleshoot further. If you can provide a self-contained reproduction that showcases the error (even occasionally) it would make further investigation a lot easier for the team. Note - can you please include a full stack trace if you have it available? This may be of further assistance as well. |
Beta Was this translation helpful? Give feedback.
-
Hi @alexbevi! Sorry it took me a while to get back to this. This is a side-project so I only work on it sporatically. Here's some details that may help. First, I have a Ruby class called
Then, in Ruby 2.3.5 using Mongoid 5.2.1, I can access this document like this:
And I have a method that accesses the value of one of the attributes via a parameter called
However, sometimes the
It just returns Fast forward to Ruby 3.1.3 and Mongoid 8.0.3: Same method, same usage, but this time with the error:
BTW, the full(er) backtrace looks like this:
I believe that trying to reference a field using the value I hope that helps to investigate. |
Beta Was this translation helpful? Give feedback.
-
Seeing the same with 8.1.4 - PR #5836 |
Beta Was this translation helpful? Give feedback.
-
Thanks for the PR @danhealy, and apologies @drsharp as it seems I've overlooked following up on this discussion. |
Beta Was this translation helpful? Give feedback.
-
I'm going to close this thread as further discussion is taking place on MONGOID-5789 and #5836 |
Beta Was this translation helpful? Give feedback.
-
Hello!
I hope this is an ok place to ask about this. I have an app that has been using mongoid for a good long while. I recently upgraded to Ruby 3.1.3 and mongoid 8.0.3 and I'm occasionally seeing this error now:
ruby/3.1.0/gems/mongoid-8.0.3/lib/mongoid/attributes.rb:266:in 'hash_dot_syntax?': undefined method 'include?' for nil:NilClass (NoMethodError)
It looks to me like the method at
mongoid/lib/mongoid/attributes.rb
Lines 271 to 273 in cb7e0bd
nil
.Tracing the call stack it seems to be from
read_raw_attribute
here:mongoid/lib/mongoid/attributes.rb
Lines 290 to 297 in cb7e0bd
normalized
via:normalized = database_field_name(name.to_s)
which is called from
read_attribute
here:mongoid/lib/mongoid/attributes.rb
Lines 86 to 90 in cb7e0bd
So then I trace it to the definition of
database_field_name
here:mongoid/lib/mongoid/fields.rb
Lines 408 to 439 in cb7e0bd
nil
. It seems that if the string passed in todatabase_field_name
is alreadynil
, it'll returnnil
and then it breaks upstream as I mentioned above.The entry of the call stack is here:
mongoid/lib/mongoid/association/proxy.rb
Lines 122 to 124 in cb7e0bd
My application was using mongoid 5.2.1 so going from 5.2.1 to 8.0.3 is a bit of a jump but it's interesting that this error is only occasionally cropping up. Also, this error is not consistent so I'm struggling how to figure out what is happening.
I think it's possible that there is a DB document that is missing an attribute and in 5.2.1 it just bubbled through as
nil
without any blow-ups, but now it's bubbling through asnil
and blowing up in thathash_dot_syntax?
check.I thought I'd start with posting here in case anyone has encountered this or has some ideas. I'm happy to provide additional info if that helps, but I thought at least mentioning the problem may be a good first step.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions