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

Database migration to v4.4.x fails with KeyError: 'formats' #12750

Closed
ridoo opened this issue Nov 27, 2024 · 1 comment · Fixed by #12751
Closed

Database migration to v4.4.x fails with KeyError: 'formats' #12750

ridoo opened this issue Nov 27, 2024 · 1 comment · Fixed by #12751
Assignees

Comments

@ridoo
Copy link
Contributor

ridoo commented Nov 27, 2024

Expected Behavior

Data migrations works fine

Actual Behavior

Migrating from v4.3.x to v4.4.x throws the following exception

django4geonode     | Running migrations:
django4geonode     |   Applying base.0092_migrate and_remove_resourcebase_files...Traceback (most recent call last):
django4geonode     |   File "/usr/src/geonode/manage.py", line 29, in <module>
django4geonode     |     execute_from_command_line(sys.argv)
django4geonode     |   File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
django4geonode     |     utility.execute()
django4geonode     |   File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 436, in execute
django4geonode     |     self.fetch_command(subcommand).run_from_argv(self.argv)
django4geonode     |   File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 412, in run_from_argv
django4geonode     |     self.execute(*args, **cmd_options)
django4geonode     |   File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 458, in execute
django4geonode     |     output = self.handle(*args, **options)
django4geonode     |   File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 106, in wrapper
django4geonode     |     res = handle_func(*args, **kwargs)
django4geonode     |   File "/usr/local/lib/python3.10/dist-packages/django/core/management/commands/migrate.py", line 356, in handle
django4geonode     |     post_migrate_state = executor.migrate(
django4geonode     |   File "/usr/local/lib/python3.10/dist-packages/django/db/migrations/executor.py", line 135, in migrate
django4geonode     |     state = self._migrate_all_forwards(
django4geonode     |   File "/usr/local/lib/python3.10/dist-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
django4geonode     |     state = self.apply_migration(
django4geonode     |   File "/usr/local/lib/python3.10/dist-packages/django/db/migrations/executor.py", line 252, in apply_migration
django4geonode     |     state = migration.apply(state, schema_editor)
django4geonode     |   File "/usr/local/lib/python3.10/dist-packages/django/db/migrations/migration.py", line 132, in apply
django4geonode     |     operation.database_forwards(
django4geonode     |   File "/usr/local/lib/python3.10/dist-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
django4geonode     |     self.code(from_state.apps, schema_editor)
django4geonode     |   File "/usr/src/geonode/geonode/base/migrations/0092_migrate and_remove_resourcebase_files.py", line 63, in migrate_files
django4geonode     |     itertools.chain.from_iterable(y for y in [x["required_ext"] for x in filetype["formats"]])
django4geonode     | KeyError: 'formats'

Steps to Reproduce the Problem

  1. Having v4.3.x database
  2. Start v4.4.x and run migrations

Additional Information

The database migration

for file in files:
for filetype in supported_file_types:
file_ext = get_ext(file)
_ext = list(
itertools.chain.from_iterable(y for y in [x["required_ext"] for x in filetype["formats"]])
)
if file_ext in _ext:
ext = filetype["id"]
break

is missing the key formats which was introduced in a later commit. v4.4.x currently does not map to the new format "required for FE" (whatever that means). Just compare it with the format mapping currently on master:

geonode/geonode/utils.py

Lines 1720 to 1735 in 993364a

# injecting the new config required for FE
default_types = [
{
"id": "zip",
"formats": [
{
"label": "Zip Archive",
"required_ext": ["zip"],
"optional_ext": ["xml", "sld"],
}
],
"actions": ["upload", "replace"],
"type": "archive",
}
]
default_types.extend(_available_settings)

/cc @gannebamm

Specifications

  • GeoNode version: v.4.4.x
  • Installation type (vanilla, geonode-project):
  • Installation method (manual, docker):
  • Platform:
  • Additional details:
@giohappy
Copy link
Contributor

giohappy commented Dec 2, 2024

@ridoo the fix has been merged.

@ridoo ridoo closed this as completed Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants