Treatment of kind field on JournalEntry is inconsistent #10873

Closed
opened 2025-12-29 21:37:06 +01:00 by adam · 1 comment
Owner

Originally created by @jeremystretch on GitHub (Mar 11, 2025).

Originally assigned to: @jeremystretch on GitHub.

Deployment Type

NetBox Cloud

NetBox Version

v4.2.5

Python Version

3.10

Steps to Reproduce

  1. View a site and click the "Journal" tab.
  2. Add a journal entry without specifying a kind.

Expected Behavior

The kind field should always be required (AFAICT):

class JournalEntry(...):
    kind = models.CharField(
        verbose_name=_('kind'),
        max_length=30,
        choices=JournalEntryKindChoices,
        default=JournalEntryKindChoices.KIND_INFO
    )

Observed Behavior

The kind field is not required by either the model's form or its REST API serializer.

class JournalEntryForm(NetBoxModelForm):
    kind = forms.ChoiceField(
        label=_('Kind'),
        choices=add_blank_choice(JournalEntryKindChoices),
        required=False
    )
class JournalEntrySerializer(NetBoxModelSerializer):
    kind = ChoiceField(
        choices=JournalEntryKindChoices,
        required=False
    )
Originally created by @jeremystretch on GitHub (Mar 11, 2025). Originally assigned to: @jeremystretch on GitHub. ### Deployment Type NetBox Cloud ### NetBox Version v4.2.5 ### Python Version 3.10 ### Steps to Reproduce 1. View a site and click the "Journal" tab. 2. Add a journal entry without specifying a kind. ### Expected Behavior The `kind` field should always be required (AFAICT): ```python class JournalEntry(...): kind = models.CharField( verbose_name=_('kind'), max_length=30, choices=JournalEntryKindChoices, default=JournalEntryKindChoices.KIND_INFO ) ``` ### Observed Behavior The `kind` field is not required by either the model's form or its REST API serializer. ```python class JournalEntryForm(NetBoxModelForm): kind = forms.ChoiceField( label=_('Kind'), choices=add_blank_choice(JournalEntryKindChoices), required=False ) ``` ```python class JournalEntrySerializer(NetBoxModelSerializer): kind = ChoiceField( choices=JournalEntryKindChoices, required=False ) ```
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:37:06 +01:00
adam closed this issue 2025-12-29 21:37:06 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 13, 2025):

When a journal entry is created via the REST API, its kind defaults to info if not specified, which is expected. The REST API will not permit kind to be empty or null.

However, a journal entry created via the web form can be created with no kind. This needs to be corrected in the form.

@jeremystretch commented on GitHub (Mar 13, 2025): When a journal entry is created via the REST API, its `kind` defaults to info if not specified, which is expected. The REST API will not permit `kind` to be empty or null. However, a journal entry created via the web form can be created with no kind. This needs to be corrected in the form.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10873