Skip to content

Wrong UN/LOCODEs in predefined base choice #19187

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

Open
Kleinrotti opened this issue Apr 15, 2025 · 2 comments · May be fixed by #19316
Open

Wrong UN/LOCODEs in predefined base choice #19187

Kleinrotti opened this issue Apr 15, 2025 · 2 comments · May be fixed by #19316
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

@Kleinrotti
Copy link

Deployment Type

Self-hosted

NetBox Version

v4.2.3

Python Version

3.12

Steps to Reproduce

  1. Create a custom field choice
  2. Use UN/LOCODE as base choice
  3. Create an object and select the unlocode

Expected Behavior

The description/name of the unlocodes should be correct.

Observed Behavior

Some or maybe many unlocodes in the predefined base choice list are wrong.
For example IT-BLQ (Bolladello, Varese, Italy). It is not Bolladello, it's Bologna.
Same for IT-BSI (Basciano, Teramo, Italy). It is not Basciano, it's Basiglio.

E.g if I search for Basciano:

Image

or Nieuwolda:

Image

@Kleinrotti Kleinrotti added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Apr 15, 2025
@jeremystretch
Copy link
Member

jeremystretch commented Apr 15, 2025

NetBox merely imports the published UN/LOCODE database. We can update the database as it appears some of these codes have been redefined, but please note that we are strictly limited to using the authoritative database; we will not make any modifications to this data within NetBox.

Edit: Direct download links

@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels Apr 15, 2025
@bctiemann
Copy link
Contributor

bctiemann commented Apr 24, 2025

This is the "code-list" file (I used the CSV, but the same data is available in all formats):

Ch | LOCODE | Name | NameWoDiacritics | SubDiv | Function | Status | Date | IATA | Coordinates | Remarks
  | AF  ASH | Ali Shirzayi | Ali Shirzayi | URU | --3----- | RQ | 1307 |   | 3252N 06603E |  
  | AF  BAG | Bagram | Bagram | PAR | --3----- | RL | 0307 |   | 3457N 06915E |  
  | AF  BIN | Bamian | Bamian |   | --34---- | AI | 0907 |   |   |  
  | AF  BEP | Bazar-E-Panjwai | Bazar-E-Panjwai | KAN | --3----- | RQ | 1001 |   | 3133N 06527E |  
  | AF  BST | Bost | Bost |   | ---4---- | AI | 9912 |   |  
...
  | CO  AAS | Acacías | Acacias | MET | -----6-- | RL | 1201 |   | 0359N 07345W |  
  | CO  ACD | Acandi | Acandi | ANT | ---4---- | RQ | 0901 |   | 0832N 07714W |  
  | CO  ARF | Acaricuara | Acaricuara | VAU | ---4---- | RL | 0907 |   | 0042N 07014W |  
  | CO  AGD | Agrado | Agrado |   | --3----- | RQ | 0607 |   | 0215N 07556W |  

But our un_locode.py file looks like this:

    ('AE-VHT', 'AE-VHT (Vopak Horizion Terminal, United Arab Emirates)'),
    ('AE-YAS', 'AE-YAS (Yas Island, United Arab Emirates)'),
    ('AE-ZUR', 'AE-ZUR (Zirku Island, United Arab Emirates)'),
    ('AF-ASH', 'AF-ASH (Ali Shirzayi, Urūzgān, Afghanistan)'),
    ('AF-BAG', 'AF-BAG (Bagram, Parwān, Afghanistan)'),
    ('AF-BIN', 'AF-BIN (Bagram, Parwān, Afghanistan)'),
    ('AF-BEP', 'AF-BEP (Bazar-E-Panjwai, Kandahār, Afghanistan)'),
    ('AF-BST', 'AF-BST (Bazar-E-Panjwai, Kandahār, Afghanistan)'),
...
    ('CO-AAS', 'CO-AAS (Acacías, Colombia)'),
    ('CO-ACD', 'CO-ACD (Acandi, Colombia)'),
    ('CO-ARF', 'CO-ARF (Acaricuara, Colombia)'),
    ('CO-AGD', 'CO-AGD (Agrado, Colombia)'),
    ('CO-AGC', 'CO-AGC (Aguachica, Colombia)'),
    ('CO-ACL', 'CO-ACL (Aguaclara, Colombia)'),

To get the latter format, you have to look up the country from the country code list, and the subdivision from the subdivision list, and concatenate them together into the format (<name-from-code-list>, <subdivision (if exists)>, <country>).

Ideally we should have a management command and a cadence to regularly import this data from the CSV set; but bear in mind that any preexisting data using this choice set will silently change for users if we periodically update from the source files.

@bctiemann bctiemann self-assigned this Apr 24, 2025
@bctiemann bctiemann 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 Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
3 participants