Skip to content

librenms_id_needs_migration misses server-scoped scalar values #97

Description

@marcinpsk

Outside-diff CodeRabbit finding on PR #87; the code is develop-owned (multi-server librenms_id introduced pre-stack), so tracking here for a develop fix.

File: netbox_librenms_plugin/import_utils/device_operations.py (VM branch ~L409-413, Device branch ~L452-456)

The librenms_id_needs_migration flag is only set for top-level legacy scalars (42 / "42"):

_vm_cf_id = existing_vm.custom_field_data.get("librenms_id")
if (isinstance(_vm_cf_id, int) and not isinstance(_vm_cf_id, bool)) or (isinstance(_vm_cf_id, str) and _vm_cf_id.isdigit()):
    result["librenms_id_needs_migration"] = True

But _describe_existing_librenms_link() also treats the server-scoped form {server_key: 42} / {server_key: "42"} as a legacy link (it unwraps cf_value.get(server_key) and coerces a scalar entry to host_id). So such records match as legacy-linked rows yet librenms_id_needs_migration stays False, and the migration path is never offered for them.

Fix: unwrap the current server_key entry before the scalar test, in both the VM and Device branches, so server-scoped scalar storage is flagged consistently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions