modoboa / modoboa-imap-migration

An extension to ease the migration between 2 IMAP servers using offlineimap
ISC License
16 stars 12 forks source link

The cron command yields a traceback and quits #7

Closed almereyda closed 7 years ago

almereyda commented 8 years ago

If one sets the shell of modoboa's vmail user to /bin/bash in /etc/passwd, the following can be reproduced with an updated modoboa instance:

# su - vmail
$ cat /etc/cron.d/modoboa
$ export PYTHON=/srv/modoboa/env/bin/python
$ export INSTANCE=/srv/modoboa/instance
$ $PYTHON $INSTANCE/manage.py generate_offlineimap_config --output .offlineimaprc

The following traceback reads

Traceback (most recent call last):
  File "/srv/modoboa/instance/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/modoboa_imap_migration/management/commands/generate_offlineimap_config.py", line 42, in handle
    "modoboa_imap_migration/offlineimap.conf", context)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/loader.py", line 97, in render_to_string
    return template.render(context, request)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/backends/django.py", line 95, in render
    return self.template.render(context)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py", line 206, in render
    return self._render(context)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py", line 197, in _render
    return self.nodelist.render(context)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py", line 992, in render
    bit = node.render_annotated(context)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py", line 959, in render_annotated
    return self.render(context)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py", line 1043, in render
    output = self.filter_expression.resolve(context)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/base.py", line 734, in resolve
    new_obj = func(obj, autoescape=context.autoescape, *arg_vals)
  File "/srv/modoboa/env/local/lib/python2.7/site-packages/django/template/defaultfilters.py", line 561, in join
    value = map(force_text, value)
TypeError: argument 2 to map() must support iteration

Triaging the errored ended up to be looking at https://github.com/modoboa/modoboa-imap-migration/blob/master/modoboa_imap_migration/management/commands/generate_offlineimap_config.py#L38 and https://github.com/modoboa/modoboa-imap-migration/blob/master/modoboa_imap_migration/templates/modoboa_imap_migration/offlineimap.conf where we learned the migrations object may not be correctly populated, but that's just a guess.

.offlineimaprc is then existing, but empty.

Rolling back such a failing plugin installation attempt is yet another story.

tonioo commented 8 years ago

Looks like the generation fails when there is nothing to migrate, do you confirm ?

almereyda commented 8 years ago

I cannot, as I don't have access to any migrations object or location where I could look for pending ones. The mailboxes I had specified were full of stuff.

On 29 July 2016 at 08:12, Antoine Nguyen notifications@github.com wrote:

Looks like the generation fails when there is nothing to migrate, do you confirm ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/modoboa/modoboa-imap-migration/issues/7#issuecomment-236102690, or mute the thread https://github.com/notifications/unsubscribe-auth/ABka_Lg80-sg3iTjqZHr8BEKnpYjjQ66ks5qaZnigaJpZM4JXijb .

tonioo commented 7 years ago

Ok, I finally reproduced this issue! It happens if you forgot to run the migrate command and try to launch the management command... Looks like the real error is catched by Django and silenced in some way.