Skip to content

Conversation

@shbatm
Copy link

@shbatm shbatm commented Jan 19, 2026

Problem

Fixes #402

When dmidecode reports multiple power supplies with identical data (common with generic/placeholder values like "Default string"), the agent attempts to create duplicate power ports in Netbox. This causes a 400 error:

RequestError: The request failed with code 400 Bad Request: {'__all__': ['Power port with this Device and Name already exists.']}

Example dmidecode output:

System Power Supply
        Power Unit Group: 1
        Location: Default string
        Name: Default string
        Manufacturer: Default string
        Serial Number: Default string
        ...
(repeated 3 times identically)

Since all PSUs have empty serial numbers, they all get name="N/A" and identical descriptions, causing Netbox to reject the duplicates.

Solution

Added deduplication logic in power.py:18-64 get_power_supply() method:

  • Track seen PSUs using a set of tuples: (serial_number, description, max_power)
  • Skip any PSU that matches a previously seen combination
  • Log skipped duplicates at DEBUG level

Changes

  • Added seen_psus set to track unique PSU combinations
  • Added duplicate check before appending PSU to the list
  • Added debug logging for skipped duplicates

Testing

With this fix, systems reporting multiple identical PSUs will only create one power port in Netbox instead of failing on duplicate creation.

🤖 Generated with Claude Code

When dmidecode reports multiple power supplies with identical data
(common with generic/placeholder values like 'Default string'), the
agent would attempt to create duplicate power ports in Netbox, causing
a 400 error on the second attempt.

Added deduplication logic in get_power_supply() to track PSUs by a
tuple of (serial_number, description, max_power) and skip duplicates.
This prevents attempting to create multiple PSUs with the same name
in Netbox.

Example case: System with 3 PSUs all reporting 'Default string' for
all fields would previously try to create 3 PSUs named 'N/A' with
identical descriptions, now only creates one.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant