diaspora/diaspora

Comment without a parent might break creating an export

tclaus opened this issue · 4 comments

It might happen, that a comment without a parent break creating a export file.

This was the stack trace then

[2021-11-09T07:47:02] ERROR PID-9364 TID-70251293490820 User: Unexpected error while exporting data for 'podmin: NoMethodError: undefined method `guid' for nil:NilClass
/mnt/disks/storage/diaspora/lib/diaspora/federation/entities.rb:50:in `comment'
/mnt/disks/storage/diaspora/lib/diaspora/federation/entities.rb:7:in `public_send'
/mnt/disks/storage/diaspora/lib/diaspora/federation/entities.rb:7:in `build'
/mnt/disks/storage/diaspora/app/serializers/federation_entity_serializer.rb:16:in `entity'
/mnt/disks/storage/diaspora/app/serializers/federation_entity_serializer.rb:12:in `modify_serializable_object'
/mnt/disks/storage/diaspora/app/serializers/export/own_relayables_serializer.rb:10:in `modify_serializable_object'
/mnt/disks/storage/diaspora/app/serializers/serializer_post_processing.rb:11:in `serializable_object'
/mnt/disks/storage/diaspora/vendor/bundle/ruby/2.6.0/gems/active_model_serializers-0.9.7/lib/active_model/serializable.rb:24:in `block in serializable_object_with_notification'
/mnt/disks/storage/diaspora/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.6/lib/active_support/notifications.rb:170:in `instrument'
/mnt/disks/storage/diaspora/vendor/bundle/ruby/2.6.0/gems/active_model_serializers-0.9.7/lib/active_model/serializable.rb:56:in `instrument'
/mnt/disks/storage/diaspora/vendor/bundle/ruby/2.6.0/gems/active_model_serializers-0.9.7/lib/active_model/serializable.rb:24:in `serializable_object_with_notification'
/mnt/disks/storage/diaspora/app/serializers/flat_map_array_serializer.rb:7:in `block (2 levels) in serializable_object'
/mnt/disks/storage/diaspora/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.6/lib/active_record/relation/batches.rb:70:in `block (2 levels) in find_each'
/mnt/disks/storage/diaspora/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.6/lib/active_record/relation/batches.rb:70:in `each'
/mnt/disks/storage/diaspora/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.6/lib/active_record/relation/batches.rb:70:in `block in find_each'

Just for the records, I found out that with
select id, guid, commentable_id from comments where commentable_id not in (select id from posts where id=comments.commentable_id);
and
select id, guid, target_type from likes where target_type = 'Post' and target_id not in (select id from posts where posts.id = likes.target_id);

I am able to get these entities without parent.

You shouldn't have a lot of them, if you have a lot, then something else is going completely wrong.

I just did these queries on my pod (existing since more than 10 years), without the author_id (so for ALL users), and I have 6 comments and 1 like without their parent ... so this happens once every year or so ... if you have more than this one, it's already a bit strange.

Also, if one of the comments or likes without parent is recent enough, so you still have logs of the creation event, this would be interesting.

To be honest, the reason is for sure that I have fiddled a bit in the beginning of the pod with its data. But even one of them stops generating the export.