django-hurricane icon indicating copy to clipboard operation
django-hurricane copied to clipboard

Error from django migration isn't visible in log, nothing happens

Open tschale opened this issue 2 years ago • 2 comments

A migration of django-filer fails when the files aren't available. In hurricanes log it looks like the following:

web_1            | Running migrations:
web_1            |   Applying filer.0012_file_mime_type...The 'file' attribute has no file associated with it.

Or just:

web_1            | Running migrations:
web_1            | The 'file' attribute has no file associated with it.

After that nothing seems to happen. The site isn't reachable, the probes seem to return a 400 at this stage (this is from a docker-compose setup, so unfortunately I can't see how this behaves on Kubernetes).

When run manually, the full stack trace is visible:

Operations to perform:
  Apply all migrations: filer
Running migrations:
  Applying filer.0012_file_mime_type...Traceback (most recent call last):
  File "/app/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python3.9/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/usr/local/lib/python3.9/site-packages/filer/migrations/0012_file_mime_type.py", line 13, in guess_mimetypes
    mime_type, _ = mimetypes.guess_type(file_obj.file.url)
  File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/files.py", line 63, in url
    self._require_file()
  File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/files.py", line 40, in _require_file
    raise ValueError("The '%s' attribute has no file associated with it." % self.field.name)
ValueError: The 'file' attribute has no file associated with it.

Is this something we want to address?

tschale avatar May 16 '22 09:05 tschale

@tschale so, the log contains the error, but not a traceback in a dockerized environment, right?

vvvityaaa avatar May 20 '22 09:05 vvvityaaa

@vvvityaaa Yes, the log contains at least the The 'file' attribute has no file associated with it. error, but not the traceback.

tschale avatar May 23 '22 07:05 tschale