-
-
Notifications
You must be signed in to change notification settings - Fork 365
Description
Is there an existing issue for this?
- I have searched the existing open and closed issues and I checked the docs https://jokob-sk.github.io/NetAlertX/
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
NetAlertX crashes when processing a device with a hostname that is composed entirely of numeric characters (e.g., 123456). The error occurs because the hostname is interpreted as an int in the database, and the backend attempts to call .lower() on it during scan processing, resulting in the following error:
AttributeError: 'int' object has no attribute 'lower'
This causes the container to become unhealthy, with the frontend throwing a 502 Bad Gateway due to the backend crash. It seems similar to a historical bug in Pi.Alert (NetAlertX's predecessor), where numeric-only hostnames also caused type mismatches in SQLite, though this particular hostname would cause it to hang rather than become entirely inaccessible in that.
Expected Behavior
Device hostnames, even if they are numeric-only (e.g., 123456), should be treated as strings throughout the processing pipeline. The backend should not crash if a device has a numeric hostname. Ideally, NetAlertX should sanitize or explicitly cast the hostname before calling .lower().
Steps To Reproduce
Set up a device (e.g., an IP camera or smart plug) on your network that has a numeric-only hostname like 123456.
Allow NetAlertX to scan the network and record that device.
Wait for the next scan cycle, or manually restart the container to trigger the scan process.
Observe the crash and check container logs. You’ll see:
name = name.lower() if name else "(unknown)"
AttributeError: 'int' object has no attribute 'lower'
app.conf
The only reason I am not going to take the time to fill this out properly is because I intend to patch and pull request this fix upstream so honestly just if you don't mind leave this here for now and I will take care of it. Too lazy to post logs, not lazy enough to not fix it myself. I'll reference this issue when I pull request. Sorry for not following usual format, but I'm a unusual kinda guy.docker-compose.yml
N/A, using docker run to test usage on my network first.What installation are you running?
Production (netalertx)
app.log
Basically: AHHHH I SEE A INT WHEN I EXPECT A STRINK TO RUN .lower() ON AND I ABSOLUTELY AM FREAKING OUT REEEEEEEEEEEEE
anyway the fix will be:
Update the backend code in device_handling.py to sanitize the name variable like this:
name = str(name).lower() if name else "(unknown)"
I can likely get this fixed relatively soon and will roll out the fix to my personal device to test since right now I can't use it on my network since I cannot change the hostname of the device, and honestly this seems a very simple thing I can fix I may as well contribute to this awesome project. Expect me to fix more stuff I run into also, since I am a user/dev/netadmin who absolutely loves this tool.
The following thing is a lie by the way, I absolutely DID NOT enable debug. Didn't need to, the docker logs showed me everything I need to see.
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.