netbox icon indicating copy to clipboard operation
netbox copied to clipboard

false positive related object in custom fields

Open opericgithub opened this issue 1 year ago • 5 comments

Deployment Type

Self-hosted

NetBox Version

v3.7.4

Python Version

3.10

Steps to Reproduce

  1. Create new custom field.
  2. Try to delete the newly created custom field.
  3. There is a message that the related object "CustomField_content_types object (n)" will also get deleted.

Expected Behavior

Newly created custom field isn't bound to any object, so user should get simple delete confirmation dialog without related objects.

Observed Behavior

User gets delete confirmation dialog with related objects even though those kinds of objects don't exist.

Another observation, don't know if it is this issue related: During the upgrade procedure to the feature branch, I get the following error mentioning the customfield_content_types:

File "/opt/netbox/venv/lib/python3.10/site-packages/psycopg/cursor.py", line 732, in execute
    raise ex.with_traceback(None)
django.db.utils.ProgrammingError: relation "extras_customfield_content_types_id_seq" does not exist

opericgithub avatar Mar 27 '24 14:03 opericgithub

User gets delete confirmation dialog with related objects even though those kinds of objects don't exist.

This is not that it is bound to a specific object, it is just stating that the custom field has a relation to the django content type table.

Technically, it is not incorrect, but I agree we should probably exempt the contenttype field from the relationship check on deletion, at least for this specific case.

DanSheps avatar Mar 28 '24 21:03 DanSheps

Thanks for clarification Dan.

Did you check, whether it has something to do with the failure of the upgrade to the feature branch?

opericgithub avatar Mar 30 '24 09:03 opericgithub

Did you check, whether it has something to do with the failure of the upgrade to the feature branch?

This would have nothing to do with it.

Please try a fresh upgrade and let us know if this fails still by opening a new bug.

DanSheps avatar Apr 03 '24 14:04 DanSheps

Thank you Dan. I just tried the upgrade from 3.7.4 as well from 3.6.9 to new v4.0-beta1 and got the same error, so it seems it has nothing to do with it. I will open a new bug issue.

opericgithub avatar Apr 03 '24 15:04 opericgithub

Could you please assign it to me?

Julio-Oliveira-Encora avatar Apr 10 '24 15:04 Julio-Oliveira-Encora