Skip to content

New devices get literal '[]' string in devParentRelType instead of the configured default #1798

Description

@Marvelous2095

Description

Every newly discovered device is inserted with devParentRelType set to the literal 4-character string "[]" instead of the configured NEWDEV_devParentRelType default ("default"). This isn't an empty/null value — it's the Python string representation of an empty list, stored verbatim in a text column that's meant to hold one of: default, child, logical, nic, virtual.

Root cause (found by reading the source)

server/plugins/newdev_template/config.json, the devParentRelType setting definition:

{
  "function": "devParentRelType",
  "type": {
    "dataType": "array",
    "elements": [
      { "elementType": "select", "elementOptions": [{ "orderable": "true"}], "transformers": ["deviceRelType"] }
    ]
  },
  "default_value": "default",
  "options": ["default", "child", "logical", "nic", "virtual"],
  ...
}

dataType is "array" (and the single select element has no "multiple": true), even though:

  • devParentRelType is a single-valued column (one relationship type per device), and
  • default_value is a plain scalar string "default", not a list.

On this instance, SELECT setValue FROM Settings WHERE setKey='NEWDEV_devParentRelType' currently returns the string '[]', not 'default' — the array-typed setting resolved to an empty-list representation instead of falling back to the scalar default_value.

server/scan/device_handling.py then inserts this raw setting value verbatim for every new device:

'{sanitize_SQL_input(get_setting_value("NEWDEV_devParentRelType"))}',

so every new device's devParentRelType becomes the literal string "[]".

Impact

  • devParentRelType no longer matches any of the 5 documented values for brand-new devices.
  • Cosmetically this happens to fall into the same "unstyled/default" bucket in the network tree color/line-style logic (getRelationshipConf() in front/js/ui_components.js only special-cases child/nic/virtual/logical), so it isn't visually obvious — but any code doing an exact comparison against "default" (or against "") will not match, and the field shows the confusing raw value [] when inspected directly (e.g. via API/DB).
  • Confirmed reproducible right now: creating a brand-new device (e.g. via ARPSCAN discovering a MAC for the first time) immediately gets devParentRelType = '[]'.

Suggested fix

Either:

  1. Change dataType to "string" for this setting (matching other genuinely single-valued select settings, e.g. ARPSCAN_RUN), since devParentRelType is not multi-valued, or
  2. If dataType: array must stay for UI reasons, fix the settings resolution so an array-typed setting with no explicit value falls back to the scalar default_value instead of producing str([]).

Environment

  • Image: ghcr.io/netalertx/netalertx (recent digest as of 2026-09-18)
  • Reproducible via: let ARPSCAN discover a brand new MAC, then check devParentRelType for that device.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Waiting for reply⏳Waiting for the original poster to respond, or discussion in progress.next release/in dev image 🚀This is coming in the next release or was already released if the issue is Closed.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions