Server Error when deleting no more existing Journal Entry Kind #8657

Closed
opened 2025-12-29 20:39:29 +01:00 by adam · 1 comment
Owner

Originally created by @advoenkin on GitHub (Sep 21, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v.3.6.2

Python version

3.10

Steps to Reproduce

  1. Go to random Location in Locations, add Journal Entry with random Kind.
  2. Go to configuration.py
  3. Setup
FIELD_CHOICES = {
    'extras.JournalEntry.kind': (
        ('something', 'Something', 'blue'),
    ),
}
  1. Go again in Location where we was add Journal Entry.
  2. Try to delete Journal Entry with no more existing Kind.

Expected Behavior

The entry should have been successfully deleted despite the fact that Kind no longer exists.

Observed Behavior

Server Error

<class 'KeyError'>

'success'

Python version: 3.10.12
NetBox version: 3.6.2
Plugins: None installed
Originally created by @advoenkin on GitHub (Sep 21, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v.3.6.2 ### Python version 3.10 ### Steps to Reproduce 1. Go to random Location in Locations, add Journal Entry with random Kind. 2. Go to configuration.py 3. Setup ```python FIELD_CHOICES = { 'extras.JournalEntry.kind': ( ('something', 'Something', 'blue'), ), } ``` 4. Go again in Location where we was add Journal Entry. 5. Try to delete Journal Entry with no more existing Kind. ### Expected Behavior The entry should have been successfully deleted despite the fact that Kind no longer exists. ### Observed Behavior Server Error ``` <class 'KeyError'> 'success' Python version: 3.10.12 NetBox version: 3.6.2 Plugins: None installed ```
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 20:39:29 +01:00
adam closed this issue 2025-12-29 20:39:29 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 21, 2023):

I've updated your example configuration above to be complete.

The root cause here is the removal of the previously valid field choice. When NetBox attempts to generate a serialized copy of the journal entry (for change logging), it cannot map the raw field value to its label. This will affect any model with a configurable choice field, not just journal entries.

There's not a lot we can do in this situation, short of (somehow) preventing administrators from removing choices which have been assigned to objects. The simplest fix would be to use either the raw field value or an empty string in place of the choice label.

@jeremystretch commented on GitHub (Sep 21, 2023): I've updated your example configuration above to be complete. The root cause here is the removal of the previously valid field choice. When NetBox attempts to generate a serialized copy of the journal entry (for change logging), it cannot map the raw field value to its label. This will affect any model with a configurable choice field, not just journal entries. There's not a lot we can do in this situation, short of (somehow) preventing administrators from removing choices which have been assigned to objects. The simplest fix would be to use either the raw field value or an empty string in place of the choice label.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8657