Skip to content

Bug: Network map crashes when devName is a number (TypeError: a.devName.localeCompare is not a function) #1281

@MicroNateId

Description

@MicroNateId

Is there an existing issue for this?

The issue occurs in the following browsers. Select at least 2.

  • Firefox
  • Chrome
  • Edge
  • Safari (unsupported) - PRs welcome
  • N/A - This is an issue with the backend

Current Behavior

The "Network" tab fails to load and remains blank if any device in the database has a numeric value for its devName (e.g., 116009949 instead of "Unknown").

This causes a Javascript crash in network.php because localeCompare cannot be called on a number.

To Reproduce

Have a device in the database where devName is a raw number (not a string).

Go to the "Network" tab.

The page remains blank.

Console shows error: Uncaught TypeError: a.devName.localeCompare is not a function at network.php:1385

Expected behavior The Network tab should load even if a device name is numeric, or it should cast numeric names to strings before sorting.

Screenshots / Logs Error in browser console:

network.php:1385 Uncaught TypeError: a.devName.localeCompare is not a function
at network.php:1385:41
at Array.sort ()
at Object.success (network.php:1377:43)
Additional context I fixed this on my local instance by finding the devices with numeric names and renaming them to text strings.

Suggested fix in network.php (around line 1385): Ensure a.devName and b.devName are cast to strings before comparison:

JavaScript

// Current likely code causing the crash:
// return a.devName.localeCompare(b.devName);

// Suggested fix:
return String(a.devName).localeCompare(String(b.devName));

Expected Behavior

Network tab should render.

Steps To Reproduce

No response

app.conf

docker-compose.yml

What installation are you running?

Production (netalertx)

app.log

No response

Debug enabled

  • I have read and followed the steps in the wiki link above and provided the required debug logs and the log section covers the time when the issue occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Docker 🐋Docker relatedbug 🐛Something isn't workingnext 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