Skip to content

fix(unifi): populate device SSIDs from wireless clients - #1836

Merged
jokob-sk merged 3 commits into
netalertx:mainfrom
itwormz:fix/unfimp-ssid
Oct 6, 2026
Merged

jokob-sk merged 3 commits into
netalertx:mainfrom
itwormz:fix/unfimp-ssid

Conversation

@itwormz

@itwormz itwormz commented Oct 6, 2026 •

Copy link
Copy Markdown

📌 Description

This fix is based on the bug report and sanitized UniFi client examples in #1832 — UNFIMP does not populate devSSID for UniFi wireless clients. The report identifies the distinction between essid and the UniFi network name, and the missing mapping to scanSSID; we independently reproduced both problems on clean upstream main and compared the proposed behavior with real data from our UniFi network.

UNFIMP imports UniFi wireless clients but leaves their device SSID empty because it reads connection_network_name and does not map its result to scanSSID.

Read the wireless SSID from essid, return an empty value for explicitly wired clients, and map extra to CurrentScan.scanSSID. Rename the displayed column from Network to SSID in its existing translations. The normal device update pipeline then applies the existing SET_ALWAYS, SET_EMPTY, and protected-field rules to devSSID.

An available essid is accepted when is_wired is absent. Network/VLAN names are not used as SSID fallbacks. Empty scan values retain the existing behavior; clearing a previously saved SSID after a connection change is outside this fix.

🔍 Related Issues

Fixes #1832.

📋 Type of Change

  • 🐛 Bug fix
  • 🧪 Test addition or change

📷 Screenshots or Logs

Before the fix, the UniFi test file reports 5 failed, 15 passed: SSID extraction, network-name confusion, wired exclusion, and scan mapping failures.

After the fix, it reports 20 passed on macOS and Debian. The Debian run covering UniFi, authoritative field rules, and plugin conventions reports 464 passed.

🧪 Testing Steps

We run a UniFi network and also checked real client data from our controller. At the time of verification, all 13 active wireless clients had a saved devSSID matching the controller's essid, while all 27 active wired clients had an empty devSSID. For all 13 wireless clients, last_connection_network_name differed from essid, confirming that a network name would be an incorrect SSID fallback in our environment.

This live verification used our existing installation with a local UNFIMP patch implementing the same SSID extraction and mapping. The isolated upstream patch was separately reproduced and tested against clean main, as described below. The live check did not exercise a Wi-Fi-to-Ethernet transition or clients with a missing is_wired flag; those edge cases were evaluated separately in code/tests.

pytest test/plugins/test_unifi_import.py -q
pytest test/scan/test_authoritative_handler.py test/plugins/test_unifi_import.py test/plugins/test_plugin_conventions.py -q --basetemp=/tmp/unfimp-focused-clean
ruff check server/plugins/unifi_import/script.py test/plugins/test_unifi_import.py
git diff --check

Regression cases include distinct SSID and network names, missing is_wired, explicitly wired clients with a stale essid, missing SSIDs, and null/empty SSIDs. The standalone test settings stub supplies UTC so tests also work when real pytz is installed.

The Debian application suite (pytest test --ignore=test/docker_tests) reports 1719 passed, 29 skipped, with 16 existing SQLite datetime-adapter deprecation warnings. Browser-dependent tests were skipped because the runner has no Chromium/ChromeDriver.

The separate Docker suite reports 73 passed, 4 failed. Three failures reproduce on unmodified main in the same Debian environment:

  • test_host_network_compose
  • test_normal_startup_no_warnings_compose
  • test_app_conf_override_file_written_from_graphql_port

The fourth, test_custom_port_without_writable_conf, passes when rerun individually on both unmodified main and the patched version. The complete suite is therefore not claimed to pass; the remaining Docker failures require separate investigation. The full suite could not be collected in the minimal macOS test environment because application dependencies and runtime paths were unavailable.

✅ Checklist

  • I have read the Contribution Guidelines.
  • I have tested the changes locally.
  • The plugin conventions tests pass.
  • The full suite passes in the configured test environment.
  • Human review of the final diff is complete.

🙋 Additional Notes

Two separate commits keep the application fix and regression tests independently reviewable:

  • 6b76b8c8 — fix(unifi): import wireless SSIDs into device scans
  • 75e427f8 — test(unifi): cover SSID extraction and scan mapping

The implementation and tests were prepared with AI assistance, reviewed by the submitter, and verified as described above.

Summary by CodeRabbit

  • Bug Fixes
    • UniFi imports now use the wireless SSID for the SSID column. Wired devices and devices without an SSID show a blank value instead of a network name.
  • Updates
    • The column is labeled “SSID” in English, Spanish, and German.

Read essid instead of the UniFi network name, exclude wired clients, and map the plugin result to scanSSID. Label the imported value as SSID.
Cover wireless, wired, missing flags, missing SSIDs, and differing network names. Keep standalone imports valid when real pytz is installed.
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: netalertx/NetAlertX/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e15b97ed-128c-449b-9ab0-71d5a5b86791
📥 Commits

Reviewing files that changed from the base of the PR and between 75e427f and 9416482.

📒 Files selected for processing (2)
  • server/plugins/unifi_import/script.py
  • test/plugins/test_unifi_import.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • server/plugins/unifi_import/script.py
  • test/plugins/test_unifi_import.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The UniFi import now uses essid for clients not explicitly marked wired and maps the value to scanSSID. Wired clients and clients without a usable essid receive an empty value. Tests cover SSID extraction and configuration mapping.

Changes

UniFi client SSID import

Layer / File(s) Summary
SSID extraction and mapping
server/plugins/unifi_import/config.json, server/plugins/unifi_import/script.py, test/plugins/test_unifi_import.py
For clients not explicitly marked wired, extra uses essid, defaulting to an empty string. Explicitly wired clients receive an empty string. The configuration labels extra as “SSID” and maps it to scanSSID. Tests cover extraction cases and mapping.

Priority: ➖ Normal

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 94164

The SSID import follows the intended mapping, with no established issue requiring a fix before merge. Normal checks remain appropriate.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: importing device SSIDs from UniFi wireless clients.
Linked Issues check ✅ Passed Issue #1832 requires UNFIMP to use essid for wireless SSIDs, leave explicitly wired clients empty, avoid network-name fallbacks, and map the value to scanSSID. The reviewed implementation and test…
Out of Scope Changes check ✅ Passed The current incremental changes document the UniFi import function and the test dependency-stub helper. These changes support the implementation and regression tests for issue #1832. No unrelated chan…
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jokob-sk

jokob-sk commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks a lot @ itwormz 🙏

@jokob-sk
jokob-sk merged commit 108320e into netalertx:main Oct 6, 2026
9 checks passed
@itwormz
itwormz deleted the fix/unfimp-ssid branch October 7, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UNFIMP does not populate devSSID for UniFi wireless clients

2 participants