Skip to content

add_device_type_components.py - Violation of not-null constraint #117

@clontarfx

Description

@clontarfx

I have tried to use this script to update an existing device that has had it's device type changed to one that contains module bays. Upon executing the script I get this failure;


Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)
psycopg.errors.NotNullViolation: null value in column "level" of relation "dcim_modulebay" violates not-null constraint
DETAIL:  Failing row contains (2025-07-01 01:38:02.8652+00, 2025-07-01 01:38:02.865232+00, {}, 30, B1, , 2, , 200, null, null, null, null, null, null).

The Device Type is a device with 8 module bays labeled B1-B6 and C1-C2. The existing device has no module bays assigned to it.

My expectation was that after changing the device to the correct device type and running this script, the device would inherit/be allocated the missing module bays from the Device Type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions