Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip some methods in BatchedRemoveStatusService when account is nil #10095

Conversation

nosada
Copy link
Contributor

@nosada nosada commented Feb 21, 2019

Sometimes bin/tootctl accounts cull fails with below error:

undefined method `followers_for_local_distribution' for nil:NilClass (NoMethodError)

This PR makes BatchedRemoveStatusService.new.call() to skip below methods when
account in it is nil:

  • unpush_from_home_timelines()
  • unpush_from_list_timelines()
  • batch_stream_entries()

Sometimes `bin/tootctl accounts cull` fails with below error:

undefined method `followers_for_local_distribution' for nil:NilClass (NoMethodError)

This commit makes BatchedRemoveStatusService to skip below methods when
`account` is nil:

- unpush_from_home_timelines()
- unpush_from_list_timelines()
- batch_stream_entries()
@nosada
Copy link
Contributor Author

nosada commented Feb 21, 2019

FYI: Below is full traceback message for this issue (/opt/mastodon/ is where mastodon code is located in my environment).

[mastodon@mstdnspawn ~]$ RAILS_ENV=production bin/tootctl accounts cull
warning: parser/current is loading parser/ruby26, which recognizes
warning: 2.6.0-compliant syntax, but you are running 2.6.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
....+.+...........+.+.....++..............+.....+...............+..............Traceback (most recent call last):
        32: from bin/tootctl:5:in `<main>'
        31: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
        30: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        29: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        28: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        27: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor.rb:238:in `block in subcommand'
        26: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:115:in `invoke'
        25: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        24: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        23: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        22: from /opt/mastodon/lib/mastodon/accounts_cli.rb:225:in `cull'
        21: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:69:in `find_each'
        20: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:135:in `find_in_batches'
        19: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:222:in `in_batches'
        18: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:222:in `loop'
        17: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:238:in `block in in_batches'
        16: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:136:in `block in find_in_batches'
        15: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:70:in `block in find_each'
        14: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:70:in `each'
        13: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:70:in `block (2 levels) in find_each'
        12: from /opt/mastodon/lib/mastodon/accounts_cli.rb:240:in `block in cull'
        11: from /opt/mastodon/app/services/suspend_account_service.rb:46:in `call'
        10: from /opt/mastodon/app/services/suspend_account_service.rb:64:in `purge_content!'
         9: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:135:in `find_in_batches'
         8: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:222:in `in_batches'
         7: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:222:in `loop'
         6: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:238:in `block in in_batches'
         5: from /opt/mastodon/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.2/lib/active_record/relation/batches.rb:136:in `block in find_in_batches'
         4: from /opt/mastodon/app/services/suspend_account_service.rb:65:in `block in purge_content!'
         3: from /opt/mastodon/app/services/batched_remove_status_service.rb:35:in `call'
         2: from /opt/mastodon/app/services/batched_remove_status_service.rb:35:in `each_value'
         1: from /opt/mastodon/app/services/batched_remove_status_service.rb:38:in `block in call'
/opt/mastodon/app/services/batched_remove_status_service.rb:65:in `unpush_from_home_timelines': undefined method `local?' for nil:NilClass (NoMethodError)

@nosada nosada force-pushed the fix/skip-batched-remove-status-service-when-account-is-nil branch from 1919411 to 8c13d7b Compare February 24, 2019 06:53
@Gargron Gargron merged commit e050958 into mastodon:master Feb 24, 2019
@nosada nosada deleted the fix/skip-batched-remove-status-service-when-account-is-nil branch March 2, 2019 05:47
hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
…astodon#10095)

* Skip some methods in BatchedRemoveStatusService when account is nil

Sometimes `bin/tootctl accounts cull` fails with below error:

undefined method `followers_for_local_distribution' for nil:NilClass (NoMethodError)

This commit makes BatchedRemoveStatusService to skip below methods when
`account` is nil:

- unpush_from_home_timelines()
- unpush_from_list_timelines()
- batch_stream_entries()

* Fix rubocop error: Use `next` to skip iteration.
messenjahofchrist pushed a commit to Origin-Creative/mastodon that referenced this pull request Jul 30, 2021
…astodon#10095)

* Skip some methods in BatchedRemoveStatusService when account is nil

Sometimes `bin/tootctl accounts cull` fails with below error:

undefined method `followers_for_local_distribution' for nil:NilClass (NoMethodError)

This commit makes BatchedRemoveStatusService to skip below methods when
`account` is nil:

- unpush_from_home_timelines()
- unpush_from_list_timelines()
- batch_stream_entries()

* Fix rubocop error: Use `next` to skip iteration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants