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

"service" does not preserve the order of ports when editing #14325

Closed
candlerb opened this issue Nov 22, 2023 · 1 comment · Fixed by #14370
Closed

"service" does not preserve the order of ports when editing #14325

candlerb opened this issue Nov 22, 2023 · 1 comment · Fixed by #14370
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

@candlerb
Copy link
Contributor

NetBox version

v3.6.5

Python version

3.8

Steps to Reproduce

  1. Create a "service", and enter the ports as "9093,9095,9998-9999"
  2. View the list of services
  3. Edit the service (i.e. click the pencil icon at the end of the service row)

Expected Behavior

Either the ports to remain in the order originally entered, or to be sorted. (I note that the data type in the underlying Postgres column is integer[] which is an ordered list)

Observed Behavior

When viewing the table of services (/ipam/services/), the ports are shown in order:

image

It also shows the same when viewing the details of an individual service (e.g. /ipam/services/2/)

However, when editing the service (/ipam/services/2/edit/), the ports are in a randomized order:

image

This matches what's in the database, which in the same randomized order:

netbox=# select ports from ipam_service where id=2
         ports
-----------------------
 {9999,9093,9998,9095}
(1 row)
@candlerb candlerb added the type: bug A confirmed report of unexpected behavior in the application label Nov 22, 2023
@candlerb candlerb changed the title "service" does not preserve the order of ports "service" does not preserve the order of ports when editing Nov 22, 2023
@abhi1693 abhi1693 added the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label Nov 22, 2023
@jeremystretch jeremystretch added the severity: low Does not significantly disrupt application functionality, or a workaround is available label Nov 28, 2023
@jeremystretch
Copy link
Member

This is due to a bug in utilities.forms.utils.parse_numeric_range(). We're calling set() on the expanded value to remove potential duplicates, but not ordering the result after casting it to a list.

@jeremystretch jeremystretch self-assigned this Nov 28, 2023
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Nov 28, 2023
jeremystretch added a commit that referenced this issue Nov 28, 2023
* Fixes #14325: Ensure expanded numeric arrays are ordered

* Remove redundant casting to
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 27, 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
Development

Successfully merging a pull request may close this issue.

3 participants