Database Migration Failure During Upgrade (custom fields) #4861

Closed
opened 2025-12-29 19:21:21 +01:00 by adam · 0 comments
Owner

Originally created by @parker-portlock on GitHub (May 3, 2021).

NetBox version

2.11.2

Python version

3.6

Steps to Reproduce

This is an upgrade from version 2.9.9 to 2.11.2 via git. I followed these instructions:

cd /opt/netbox
sudo git checkout master
sudo git pull origin master

It looks to have errored out on one of my custom fields. They are configured as follows:

Screen Shot 2021-05-03 at 3 32 22 PM Screen Shot 2021-05-03 at 3 32 13 PM

Host OS: Ubuntu 18.04
Postgres version: psql (PostgreSQL) 10.16 (Ubuntu 10.16-0ubuntu0.18.04.1)
Python version: Python 3.6.9

Expected Behavior

Expected behavior: upgrade completed without issues.

Observed Behavior

ValueError occurred during the database migration:

Running migrations:
  Applying virtualization.0018_custom_field_data... OK
  Applying tenancy.0010_custom_field_data... OK
  Applying secrets.0010_custom_field_data... OK
  Applying ipam.0038_custom_field_data... OK
  Applying extras.0048_exporttemplate_remove_template_language... OK
  Applying extras.0049_remove_graph... OK
  Applying extras.0050_customfield_changes... OK
  Applying dcim.0117_custom_field_data... OK
  Applying circuits.0020_custom_field_data... OK
  Applying extras.0051_migrate_customfields...AWS Region (select): us-east-1 (35)
Traceback (most recent call last):
  File "netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 246, in handle
    fake_initial=fake_initial,
  File "/opt/netbox/venv/lib/python3.6/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 "/opt/netbox/venv/lib/python3.6/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 "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/opt/netbox/netbox/extras/migrations/0051_migrate_customfields.py", line 72, in migrate_customfieldvalues
    raise e
  File "/opt/netbox/netbox/extras/migrations/0051_migrate_customfields.py", line 69, in migrate_customfieldvalues
    cf_data['custom_field_data'][cfv.field.name] = deserialize_value(cfv.field, cfv.serialized_value)
  File "/opt/netbox/netbox/extras/migrations/0051_migrate_customfields.py", line 15, in deserialize_value
    return field._choices.get(pk=int(value)).value
ValueError: invalid literal for int() with base 10: 'us-east-1'
Originally created by @parker-portlock on GitHub (May 3, 2021). ### NetBox version 2.11.2 ### Python version 3.6 ### Steps to Reproduce This is an upgrade from version 2.9.9 to 2.11.2 via git. I followed these instructions: ``` cd /opt/netbox sudo git checkout master sudo git pull origin master ``` It looks to have errored out on one of my custom fields. They are configured as follows: <img width="1002" alt="Screen Shot 2021-05-03 at 3 32 22 PM" src="https://user-images.githubusercontent.com/2265775/116930021-d22e9380-ac24-11eb-8d5d-e5214149d62f.png"> <img width="798" alt="Screen Shot 2021-05-03 at 3 32 13 PM" src="https://user-images.githubusercontent.com/2265775/116930068-e5416380-ac24-11eb-8113-db8adf9e5e15.png"> Host OS: Ubuntu 18.04 Postgres version: psql (PostgreSQL) 10.16 (Ubuntu 10.16-0ubuntu0.18.04.1) Python version: Python 3.6.9 ### Expected Behavior Expected behavior: upgrade completed without issues. ### Observed Behavior ValueError occurred during the database migration: ``` Running migrations: Applying virtualization.0018_custom_field_data... OK Applying tenancy.0010_custom_field_data... OK Applying secrets.0010_custom_field_data... OK Applying ipam.0038_custom_field_data... OK Applying extras.0048_exporttemplate_remove_template_language... OK Applying extras.0049_remove_graph... OK Applying extras.0050_customfield_changes... OK Applying dcim.0117_custom_field_data... OK Applying circuits.0020_custom_field_data... OK Applying extras.0051_migrate_customfields...AWS Region (select): us-east-1 (35) Traceback (most recent call last): File "netbox/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options) File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/base.py", line 89, in wrapped res = handle_func(*args, **kwargs) File "/opt/netbox/venv/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 246, in handle fake_initial=fake_initial, File "/opt/netbox/venv/lib/python3.6/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 "/opt/netbox/venv/lib/python3.6/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 "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/executor.py", line 227, in apply_migration state = migration.apply(state, schema_editor) File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/migration.py", line 126, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/opt/netbox/venv/lib/python3.6/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards self.code(from_state.apps, schema_editor) File "/opt/netbox/netbox/extras/migrations/0051_migrate_customfields.py", line 72, in migrate_customfieldvalues raise e File "/opt/netbox/netbox/extras/migrations/0051_migrate_customfields.py", line 69, in migrate_customfieldvalues cf_data['custom_field_data'][cfv.field.name] = deserialize_value(cfv.field, cfv.serialized_value) File "/opt/netbox/netbox/extras/migrations/0051_migrate_customfields.py", line 15, in deserialize_value return field._choices.get(pk=int(value)).value ValueError: invalid literal for int() with base 10: 'us-east-1' ```
adam added the type: bug label 2025-12-29 19:21:21 +01:00
adam closed this issue 2025-12-29 19:21:21 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4861