Service Port cannot be set to 0 #3040

Closed
opened 2025-12-29 18:25:04 +01:00 by adam · 4 comments
Owner

Originally created by @kevinreniers on GitHub (Dec 4, 2019).

Environment

  • Python version: 3.7
  • NetBox version: 2.6.7

Steps to Reproduce

  1. Try to set the port of a device service to 0

Expected Behavior

Client-side validation seems to allow this because the min value is set to 0.

Snippet:

<input type="number" name="port" value="0" min="0" class="form-control" required="" placeholder="Port number" id="id_port">

Server-side validation seems to restrict this min value to 1.

We would like to use "0" as a way to model "All Ports".

Observed Behavior

Form reloads and nothing happens.
Entering -1 also generates a client-side validation "value should be greater than or equal to 0".

Originally created by @kevinreniers on GitHub (Dec 4, 2019). ### Environment * Python version: 3.7 * NetBox version: 2.6.7 ### Steps to Reproduce 1. Try to set the port of a device service to 0 ### Expected Behavior Client-side validation seems to allow this because the min value is set to 0. Snippet: ```html <input type="number" name="port" value="0" min="0" class="form-control" required="" placeholder="Port number" id="id_port"> ``` Server-side validation seems to restrict this min value to 1. We would like to use "0" as a way to model "All Ports". ### Observed Behavior Form reloads and nothing happens. Entering -1 also generates a client-side validation "value should be greater than or equal to 0".
adam added the type: bugstatus: accepted labels 2025-12-29 18:25:04 +01:00
adam closed this issue 2025-12-29 18:25:04 +01:00
Author
Owner

@ghost commented on GitHub (Dec 5, 2019):

Just out of interest, can you not resort to using a custom field instead of marking it as 0?

@ghost commented on GitHub (Dec 5, 2019): Just out of interest, can you not resort to using a custom field instead of marking it as 0?
Author
Owner

@kevinreniers commented on GitHub (Dec 5, 2019):

Definitely as a workaround. I would prefer to limit the use of custom fields to a bare minimum if we can model it using standard fields, though.

@kevinreniers commented on GitHub (Dec 5, 2019): Definitely as a workaround. I would prefer to limit the use of custom fields to a bare minimum if we can model it using standard fields, though.
Author
Owner

@jeremystretch commented on GitHub (Dec 5, 2019):

We would like to use "0" as a way to model "All Ports".

This would not be a valid use of this field. This field reflects a specific port number, thus zero is not a valid value.

This is a bug only so far that the client side validation for the field specifies the minimum value as zero rather than one.

@jeremystretch commented on GitHub (Dec 5, 2019): > We would like to use "0" as a way to model "All Ports". This would not be a valid use of this field. This field reflects a specific port number, thus zero is not a valid value. This is a bug only so far that the client side validation for the field specifies the minimum value as zero rather than one.
Author
Owner

@kevinreniers commented on GitHub (Dec 6, 2019):

Thank you for the feedback. 😃

What would be your recommendation on modelling an F5 or Citrix virtual server that listens on all ports and is configured with 0 or *?

We have a few use cases like this that we would like to accurately and idiomatically use netbox as a source-of-truth for.

Since the port field is required, the recommendation of @ahmed-cader would not be entirely appropriate. Tagging, likewise, still forces an invalid value in the port field.

@kevinreniers commented on GitHub (Dec 6, 2019): Thank you for the feedback. 😃 What would be your recommendation on modelling an F5 or Citrix virtual server that listens on all ports and is configured with `0` or `*`? We have a few use cases like this that we would like to accurately and idiomatically use netbox as a source-of-truth for. Since the port field is required, the recommendation of @ahmed-cader would not be entirely appropriate. Tagging, likewise, still forces an invalid value in the port field.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3040