renatoalmeidaoliveira/nbrisk

NBRisk 0.3.0 Update Errors

cyberndj opened this issue · 5 comments

Howdy,

I tried updating my environment this morning with the newest 0.3.0 update. It failed with the following output. Any help you could give is much appreciative!

Thanks!
-Jake

Edit: I realized I wasn't in the virtual environment. Tried in the venv with the same error message.

(venv) root@69264654cc43:/opt/netbox/netbox# pip3 install nbrisk==0.3.0
Collecting nbrisk==0.3.0
Downloading NbRisk-0.3.0-py3-none-any.whl (29 kB)
Installing collected packages: nbrisk
Attempting uninstall: nbrisk
Found existing installation: NbRisk 0.2.0
Uninstalling NbRisk-0.2.0:
Successfully uninstalled NbRisk-0.2.0
Successfully installed nbrisk-0.3.0
(venv) root@69264654cc43:/opt/netbox/netbox# python3 manage.py migrate nb_risk
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
Operations to perform:
Apply all migrations: nb_risk
Running migrations:
Applying nb_risk.0003_alter_vulnerability_cvssbasescore...Traceback (most recent call last):
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type double precision: ""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/netbox/netbox/manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/init.py", line 446, in execute_from_command_line
utility.execute()
File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/init.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute
output = self.handle(*args, **options)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 96, in wrapped
res = handle_func(*args, **kwargs)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 349, in handle
post_migrate_state = executor.migrate(
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/migrations/migration.py", line 130, in apply
operation.database_forwards(
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/migrations/operations/fields.py", line 235, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 788, in alter_field
self._alter_field(
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/postgresql/schema.py", line 245, in _alter_field
super()._alter_field(
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 1007, in _alter_field
self.execute(
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 199, in execute
cursor.execute(sql, params)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
with self.db.wrap_database_errors:
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
django.db.utils.DataError: invalid input syntax for type double precision: ""

Thank you for the report, its a code error to fix it please run:

source /opt/netbox/venv/bin/activate
cd /opt/netbox/netbox
./manage.py showmigrations nb_risk

You should see this output:

nb_risk
 [X] 0001_initial
 [X] 0002_vulnerability_cvssaccesscomplexity_and_more
 [ ] 0003_alter_vulnerability_cvssbasescore

Then run this:

./manage.py migrate nb_risk 0001

You should see this output:

Operations to perform:
  Target specific migration: 0001_initial, from nb_risk
Running migrations:
  Rendering model states... DONE
  Unapplying nb_risk.0002_vulnerability_cvssaccesscomplexity_and_more... OK

Run this again:

./manage.py showmigrations nb_risk

You shoud see:

nb_risk
 [X] 0001_initial
 [ ] 0002_vulnerability_cvssaccesscomplexity_and_more
 [ ] 0003_alter_vulnerability_cvssbasescor

Now reinstall NBRisk in the version 0.3.1:

pip install NbRisk==0.3.1
./manage.py migrate nb_risk
systemctl restart netbox netbox-rq

Howdy,
I ran the fix this morning. I ran it twice because I didn't see the 0003_alter_vulnerability_cvssbasescor migration happen. I couldn't run the systemctl restart command so I restarted by docker container instead. Output is below for reference.

Some very good progress happening! I appreciate the work you've put in for it.

`root@6e10cd3dd291:/opt/netbox/netbox# source /opt/netbox/venv/bin/activate
(venv) root@6e10cd3dd291:/opt/netbox/netbox# cd /opt/netbox/netbox
(venv) root@6e10cd3dd291:/opt/netbox/netbox# ./manage.py showmigrations nb_risk
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
nb_risk
[X] 0001_initial
[X] 0002_vulnerability_cvssaccesscomplexity_and_more
(venv) root@6e10cd3dd291:/opt/netbox/netbox# ./manage.py migrate nb_risk 0001
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
Operations to perform:
Target specific migration: 0001_initial, from nb_risk
Running migrations:
Rendering model states... DONE
Unapplying nb_risk.0002_vulnerability_cvssaccesscomplexity_and_more... OK
(venv) root@6e10cd3dd291:/opt/netbox/netbox# ./manage.py showmigrations nb_risk
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
nb_risk
[X] 0001_initial
[ ] 0002_vulnerability_cvssaccesscomplexity_and_more
(venv) root@6e10cd3dd291:/opt/netbox/netbox# pip install NbRisk==0.3.1
Requirement already satisfied: NbRisk==0.3.1 in /opt/netbox/venv/lib/python3.10/site-packages (0.3.1)

[notice] A new release of pip is available: 23.0.1 -> 23.1
[notice] To update, run: pip install --upgrade pip
(venv) root@6e10cd3dd291:/opt/netbox/netbox# ./manage.py migrate nb_risk
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
Operations to perform:
Apply all migrations: nb_risk
Running migrations:
Applying nb_risk.0002_vulnerability_cvssaccesscomplexity_and_more... OK
(venv) root@6e10cd3dd291:/opt/netbox/netbox# ./manage.py showmigrations nb_risk
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
nb_risk
[X] 0001_initial
[X] 0002_vulnerability_cvssaccesscomplexity_and_more
(venv) root@6e10cd3dd291:/opt/netbox/netbox# `

But its working now? Or you have some other errors?

It is working now. No other errors (at least regarding NBRisk).

@cyberndj cool, gonna close the issue. And dont forget to update to 0.4.0 I've added the Control model.