[PR #18135] [CLOSED] Fixes: #18032 - Clear ordering preferences if set to a nonexistent field #15279

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/18135
Author: @bctiemann
Created: 12/2/2024
Status: Closed

Base: developHead: 18032-clear-stale-ordering-column-on-fielderror


📝 Commits (1)

  • 93821ca Clear ordering preferences if set to a nonexistent field (i.e. if upgrading to a version with changed fields)

📊 Changes

1 file changed (+6 additions, -2 deletions)

View changed files

📝 netbox/netbox/tables/tables.py (+6 -2)

📄 Description

Fixes: #18032

It is possible to have a user preference set to a field which no longer exists in a new version of NetBox after an upgrade. Normally django-tables2 validates all sort=<column> query params against the table's columns and filters out any invalid values prior to storage as a preference; but if a sort value that was previously (but is no longer) valid has been stored in the preferences, a FieldError will be raised under the new version.

This change catches that FieldError and clears the preference accordingly.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/18135 **Author:** [@bctiemann](https://github.com/bctiemann) **Created:** 12/2/2024 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `18032-clear-stale-ordering-column-on-fielderror` --- ### 📝 Commits (1) - [`93821ca`](https://github.com/netbox-community/netbox/commit/93821ca0eaa4cd6f7af36676bcf58b81903cd156) Clear ordering preferences if set to a nonexistent field (i.e. if upgrading to a version with changed fields) ### 📊 Changes **1 file changed** (+6 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `netbox/netbox/tables/tables.py` (+6 -2) </details> ### 📄 Description ### Fixes: #18032 It is possible to have a user preference set to a field which no longer exists in a new version of NetBox after an upgrade. Normally django-tables2 validates all `sort=<column>` query params against the table's `columns` and filters out any invalid values prior to storage as a preference; but if a `sort` value that was previously (but is no longer) valid has been stored in the preferences, a `FieldError` will be raised under the new version. This change catches that `FieldError` and clears the preference accordingly. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:21:02 +01:00
adam closed this issue 2025-12-30 00:21:02 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15279