Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
advoenkin opened this issue Sep 21, 2023 · 1 comment · Fixed by #13867
Closed

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

advoenkin opened this issue Sep 21, 2023 · 1 comment · Fixed by #13867
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@advoenkin
Copy link

advoenkin commented Sep 21, 2023

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
@advoenkin advoenkin added the type: bug A confirmed report of unexpected behavior in the application label Sep 21, 2023
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation severity: low Does not significantly disrupt application functionality, or a workaround is available labels Sep 21, 2023
@jeremystretch jeremystretch self-assigned this Sep 21, 2023
@jeremystretch
Copy link
Member

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 added a commit that referenced this issue Sep 26, 2023
…ield choices (#13867)

* Fixes #13849: Fix label resolution during serialization for removed field choices

* Cleanup
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
2 participants