Importing YAML breaks sequence IDs #11621

Closed
opened 2025-12-29 21:47:44 +01:00 by adam · 4 comments
Owner

Originally created by @Etibru on GitHub (Sep 17, 2025).

NetBox Edition

NetBox Community

NetBox Version

v4.2.7

Python Version

3.10

Steps to Reproduce

  1. Import a YAML of Device Type (with, interfaces, power port, ...)
    ex:
manufacturer: Legrand
model: PX4-2699-E7V2
slug: legrand-px4-2699-e7v2
description: ''
default_platform: null
part_number: PX4-2699-E7V2
u_height: 0.0
is_full_depth: false
subdevice_role: null
airflow: null
weight: 7.8
weight_unit: kg
comments: '[Rack PDU | PX4-2699-E7V2 | Product Selector - Raritan](https://www.raritan.com/product-selector/pdu-detail/PX4-2699-E7V2)'
power-ports:
- name: Power Port 1
  type: iec-60309-3p-n-e-6h
  maximum_draw: 22200
  allocated_draw: null
  label: ''
  description: ''
power-outlets:
- name: Outlet 1.1
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.2
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.3
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.4
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.5
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.6
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.7
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.8
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.9
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.10
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.11
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.12
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.13
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
- name: Outlet 1.14
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
- name: Outlet 1.15
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
- name: Outlet 1.16
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
- name: Outlet 1.17
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
- name: Outlet 1.18
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
- name: Outlet 1.19
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.20
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.21
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.22
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.23
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.24
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: A
  label: ''
  description: ''
- name: Outlet 1.25
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.26
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.27
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.28
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.29
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.30
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: B
  label: ''
  description: ''
- name: Outlet 1.31
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
- name: Outlet 1.32
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
- name: Outlet 1.33
  type: iec-60320-c13
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
- name: Outlet 1.34
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
- name: Outlet 1.35
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
- name: Outlet 1.36
  type: hdot-cx
  power_port: Power Port 1
  feed_leg: C
  label: ''
  description: ''
interfaces:
- name: Link-a
  type: 100base-tx
  enabled: true
  mgmt_only: false
  label: ''
  description: ''
  bridge: null
  poe_mode: null
  poe_type: null
  rf_role: null
- name: Link-b
  type: 100base-tx
  enabled: true
  mgmt_only: true
  label: ''
  description: ''
  bridge: null
  poe_mode: null
  poe_type: null
  rf_role: null
  1. Create another device type and add manually an interface, power port, ... (objects of the type previously created by the import)
  2. Internal Server error

Expected Behavior

Importing an object should not redefine session IDs in the database.

Observed Behavior

Pkey already exists :

Image

To solve the problem, you must go through the database like this:
SELECT setval('dcim_powerporttemplate_id_seq', (SELECT MAX(id) from dcim_powerporttemplate));

Originally created by @Etibru on GitHub (Sep 17, 2025). ### NetBox Edition NetBox Community ### NetBox Version v4.2.7 ### Python Version 3.10 ### Steps to Reproduce 1. Import a YAML of Device Type (with, interfaces, power port, ...) ex: ```yaml manufacturer: Legrand model: PX4-2699-E7V2 slug: legrand-px4-2699-e7v2 description: '' default_platform: null part_number: PX4-2699-E7V2 u_height: 0.0 is_full_depth: false subdevice_role: null airflow: null weight: 7.8 weight_unit: kg comments: '[Rack PDU | PX4-2699-E7V2 | Product Selector - Raritan](https://www.raritan.com/product-selector/pdu-detail/PX4-2699-E7V2)' power-ports: - name: Power Port 1 type: iec-60309-3p-n-e-6h maximum_draw: 22200 allocated_draw: null label: '' description: '' power-outlets: - name: Outlet 1.1 type: iec-60320-c13 power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.2 type: iec-60320-c13 power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.3 type: iec-60320-c13 power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.4 type: hdot-cx power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.5 type: hdot-cx power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.6 type: hdot-cx power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.7 type: iec-60320-c13 power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.8 type: iec-60320-c13 power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.9 type: iec-60320-c13 power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.10 type: hdot-cx power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.11 type: hdot-cx power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.12 type: hdot-cx power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.13 type: iec-60320-c13 power_port: Power Port 1 feed_leg: C label: '' description: '' - name: Outlet 1.14 type: iec-60320-c13 power_port: Power Port 1 feed_leg: C label: '' description: '' - name: Outlet 1.15 type: iec-60320-c13 power_port: Power Port 1 feed_leg: C label: '' description: '' - name: Outlet 1.16 type: hdot-cx power_port: Power Port 1 feed_leg: C label: '' description: '' - name: Outlet 1.17 type: hdot-cx power_port: Power Port 1 feed_leg: C label: '' description: '' - name: Outlet 1.18 type: hdot-cx power_port: Power Port 1 feed_leg: C label: '' description: '' - name: Outlet 1.19 type: iec-60320-c13 power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.20 type: iec-60320-c13 power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.21 type: iec-60320-c13 power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.22 type: hdot-cx power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.23 type: hdot-cx power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.24 type: hdot-cx power_port: Power Port 1 feed_leg: A label: '' description: '' - name: Outlet 1.25 type: iec-60320-c13 power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.26 type: iec-60320-c13 power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.27 type: iec-60320-c13 power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.28 type: hdot-cx power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.29 type: hdot-cx power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.30 type: hdot-cx power_port: Power Port 1 feed_leg: B label: '' description: '' - name: Outlet 1.31 type: iec-60320-c13 power_port: Power Port 1 feed_leg: C label: '' description: '' - name: Outlet 1.32 type: iec-60320-c13 power_port: Power Port 1 feed_leg: C label: '' description: '' - name: Outlet 1.33 type: iec-60320-c13 power_port: Power Port 1 feed_leg: C label: '' description: '' - name: Outlet 1.34 type: hdot-cx power_port: Power Port 1 feed_leg: C label: '' description: '' - name: Outlet 1.35 type: hdot-cx power_port: Power Port 1 feed_leg: C label: '' description: '' - name: Outlet 1.36 type: hdot-cx power_port: Power Port 1 feed_leg: C label: '' description: '' interfaces: - name: Link-a type: 100base-tx enabled: true mgmt_only: false label: '' description: '' bridge: null poe_mode: null poe_type: null rf_role: null - name: Link-b type: 100base-tx enabled: true mgmt_only: true label: '' description: '' bridge: null poe_mode: null poe_type: null rf_role: null ``` 2. Create another device type and add manually an interface, power port, ... (objects of the type previously created by the import) 3. Internal Server error ### Expected Behavior Importing an object should not redefine session IDs in the database. ### Observed Behavior Pkey already exists : <img width="1027" height="534" alt="Image" src="https://github.com/user-attachments/assets/67dbecbe-fdaf-4716-90fd-450c27d42507" /> To solve the problem, you must go through the database like this: `SELECT setval('dcim_powerporttemplate_id_seq', (SELECT MAX(id) from dcim_powerporttemplate));`
adam added the type: bugpending closure labels 2025-12-29 21:47:44 +01:00
adam closed this issue 2025-12-29 21:47:44 +01:00
Author
Owner

@jnovinger commented on GitHub (Sep 17, 2025):

@Etibru , thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v4.4.0 (the latest minor release) or v4.4.1 (the latest patch release). Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data.

@jnovinger commented on GitHub (Sep 17, 2025): @Etibru , thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v4.4.0 (the latest minor release) or v4.4.1 (the latest patch release). Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data.
Author
Owner

@Etibru commented on GitHub (Sep 17, 2025):

Actually, I tested it on the latest version, and I wasn't able to reproduce the same bug. I tested it again on another Netbox (v4.2.7) and I couldn't reproduce the bug. Apparently, it's more complicated than I thought to trigger it.
I would still say that it's related to YAML/CSV imports, given that the error with id=836 refers to an old element imported by YAML/CSV.
I'm confused :(
In any case, we've already had this error on the dcim_interfacetemplate_pkey dcim_powerporttemplate_pkey

Maybe there's a correlation with that : https://stackoverflow.com/questions/41916225/python-django-key-already-exists-postgres

@Etibru commented on GitHub (Sep 17, 2025): Actually, I tested it on the latest version, and I wasn't able to reproduce the same bug. I tested it again on another Netbox (v4.2.7) and I couldn't reproduce the bug. Apparently, it's more complicated than I thought to trigger it. I would still say that it's related to YAML/CSV imports, given that the error with id=836 refers to an old element imported by YAML/CSV. I'm confused :( In any case, we've already had this error on the `dcim_interfacetemplate_pkey ` `dcim_powerporttemplate_pkey` Maybe there's a correlation with that : https://stackoverflow.com/questions/41916225/python-django-key-already-exists-postgres
Author
Owner

@github-actions[bot] commented on GitHub (Sep 25, 2025):

This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.

@github-actions[bot] commented on GitHub (Sep 25, 2025): This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 3, 2025):

This issue is being closed as no further information has been provided. If you would like to revisit this topic, please first modify your original post to include all the requested detail, and then ask that the issue be reopened.

@github-actions[bot] commented on GitHub (Oct 3, 2025): This issue is being closed as no further information has been provided. If you would like to revisit this topic, please first modify your original post to include all the requested detail, and then ask that the issue be reopened.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11621