Skip to content

FieldError upon sorting by contact group #20441

@tacerus

Description

@tacerus

NetBox Edition

NetBox Community

NetBox Version

v4.4.1

Python Version

3.11

Steps to Reproduce

  1. Open the contacts view of any device (/dcim/devices/xxx/contacts)
  2. Use "Configure Table" to add the "Group" column
  3. Click "GROUP" to sort by Contact Group
    • this does not work reliably, it seems sometimes it is rendered with href="" instead of href="#"
    • alternatively manually add the query parameter ?sort=contact_group

Note that whilst reproduced and reported against the latest version of NetBox at the time of writing, the problem was already observed with earlier versions.

Expected Behavior

  • No error should be returned, the list of contacts should be sorted by contact group.
  • The broken preference should not be persisted into the database.

Observed Behavior

FieldError at /dcim/devices/37122/contacts/

Cannot resolve keyword 'group' into field. Choices are: address, assignments, bookmarks, comments, created, custom_field_data, description, email, groups, id, journal_entries, last_updated, link, name, phone, subscriptions, tagged_items, tags, title

Find the traceback here.

Worse, the user is now locked out from loading the /contacts view, as the problem was also written into the database:

SELECT users_userconfig.id, data->'tables'->'ContactAssignmentTable' AS x FROM users_userconfig INNER JOIN users_user ON users_user.id = user_id WHERE username = 'myuser';
1|{"columns": ["object_type", "object", "contact", "role", "priority", "contact_email", "contact_phone", "contact_group"], "ordering": ["contact_group"]}

To "repair" the user, an administrator needs to manually remove the offending entry from the JSON (as there is only one entry in the list, I just delete the whole ordering key for simplicity):

UPDATE users_userconfig SET data = data #- '{tables, ContactAssignmentTable, ordering}' WHERE id = 1;
UPDATE 1

This lasts until the user clicks "GROUP" again. ;-)

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions