Skip to content

Next release#1604

Merged
jokob-sk merged 4 commits intomainfrom
next_release
Apr 10, 2026
Merged

Next release#1604
jokob-sk merged 4 commits intomainfrom
next_release

Conversation

@jokob-sk
Copy link
Copy Markdown
Collaborator

@jokob-sk jokob-sk commented Apr 10, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Devices marked forced-online (case-insensitive "online") are excluded from triggering "Device Down" or "Disconnected" events across all down/dormant detection paths.
  • Refactor

    • Guest Wi‑Fi device MAC is now derived from the Fritz!Box hardware MAC or a fixed sentinel when unavailable, removing prior host-based fallback.
  • Tests

    • Added tests for forced-online suppression; test helpers updated to allow setting forced-online status.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

Added a SQL predicate to exclude devices with devForceStatus='online' (case-insensitive) from "Device Down" and "Disconnected" INSERTs; updated test helpers and added tests to verify forced-online suppression. Also changed Fritz!Box guest-MAC generation to use device MAC or a fixed sentinel.

Changes

Cohort / File(s) Summary
Event Insertion Logic
server/scan/session_events.py
Added _SQL_NOT_FORCED_ONLINE (LOWER(COALESCE(devForceStatus, '')) != 'online') and applied it to the three negative-event INSERT branches to prevent inserting "Device Down" / "Disconnected" for forced-online devices.
Test Helper Updates
test/db_test_helpers.py
Extended insert_device() signature with `force_status: str
Test Coverage — Down/Sleep
test/scan/test_down_sleep_events.py
Added TestInsertEventsForceOnline tests verifying that devForceStatus='online' (case-insensitive) suppresses "Device Down" and "Disconnected" events across immediate, sleep-expired, and alert scenarios; ensures non-forced statuses still produce events.
Fritz!Box: Guest MAC change
front/plugins/fritzbox/fritzbox.py
Removed host parameter from create_guest_wifi_device; guest-MAC is now derived from Fritz!Box MAC when available, otherwise uses sentinel 'FRITZBOX_GUEST'. Call site updated accordingly.
Fritz!Box Tests
test/plugins/test_fritzbox.py
Updated tests to use utils.crypto_utils.string_to_fake_mac for guest-MAC expectations, changed sentinel fallback to string_to_fake_mac("FRITZBOX_GUEST"), and simplified mocking for Fritz!Box connection/hosts.

Poem

🐇 I nibble the logs with a careful nose,

I hop where the sleeping network goes,
I fold "online" in lowercase done,
So Down and Lost see no rising sun,
A rabbit's cheer for quieter runs!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The pull request title 'Next release' is vague and generic, using non-descriptive terms that do not convey meaningful information about the actual changeset. Replace the generic title with a specific summary of the main changes, such as 'Add forced-online device status filtering and improve Fritz!Box guest WiFi device identification' to clearly communicate the primary modifications.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch next_release

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
server/scan/session_events.py (1)

182-182: Consider centralizing the forced-online predicate.

The same LOWER(COALESCE(devForceStatus, '')) != 'online' fragment now lives in three separate INSERTs. Pulling it into one shared SQL snippet/constant would make future event-path edits less likely to miss one branch.

Also applies to: 198-198, 234-234


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d5e187b7-ddb2-4ca5-9d04-00bdbd4ae227

📥 Commits

Reviewing files that changed from the base of the PR and between c40d04b and 50be56c.

📒 Files selected for processing (3)
  • server/scan/session_events.py
  • test/db_test_helpers.py
  • test/scan/test_down_sleep_events.py

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@front/plugins/fritzbox/fritzbox.py`:
- Around line 177-178: The current fallback uses raw truthiness of fritzbox_mac
which allows values like whitespace or an invalid MAC to slip through; update
the guest_mac creation by first calling normalize_mac(fritzbox_mac) (or '' if
fritzbox_mac is None), then check the normalized result (e.g., truthy after
strip) and only use it if valid, otherwise use the sentinel 'FRITZBOX_GUEST' as
the seed passed into string_to_fake_mac; modify the code around fritzbox_mac and
guest_mac so string_to_fake_mac receives either the normalized MAC or the
sentinel, not the original raw value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a78d2bbc-192a-4d8e-9ac5-b5a74fab0eb8

📥 Commits

Reviewing files that changed from the base of the PR and between c80dc9c and 51b8cf0.

📒 Files selected for processing (2)
  • front/plugins/fritzbox/fritzbox.py
  • test/plugins/test_fritzbox.py

Comment on lines 177 to +178
fritzbox_mac = fc.call_action('DeviceInfo:1', 'GetInfo').get('NewMACAddress', '')
guest_mac = string_to_fake_mac(normalize_mac(fritzbox_mac) if fritzbox_mac else host)
guest_mac = string_to_fake_mac(normalize_mac(fritzbox_mac) if fritzbox_mac else 'FRITZBOX_GUEST')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Harden fallback when MAC is present-but-invalid/blank.

At Line 178, fallback only checks raw truthiness. Values like whitespace can normalize to an empty string and produce a hash seed of "" instead of the sentinel fallback.

Proposed fix
-        fritzbox_mac = fc.call_action('DeviceInfo:1', 'GetInfo').get('NewMACAddress', '')
-        guest_mac = string_to_fake_mac(normalize_mac(fritzbox_mac) if fritzbox_mac else 'FRITZBOX_GUEST')
+        fritzbox_mac = fc.call_action('DeviceInfo:1', 'GetInfo').get('NewMACAddress', '')
+        normalized_mac = normalize_mac(fritzbox_mac) if fritzbox_mac else ''
+        guest_mac = string_to_fake_mac(normalized_mac if normalized_mac else 'FRITZBOX_GUEST')
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@front/plugins/fritzbox/fritzbox.py` around lines 177 - 178, The current
fallback uses raw truthiness of fritzbox_mac which allows values like whitespace
or an invalid MAC to slip through; update the guest_mac creation by first
calling normalize_mac(fritzbox_mac) (or '' if fritzbox_mac is None), then check
the normalized result (e.g., truthy after strip) and only use it if valid,
otherwise use the sentinel 'FRITZBOX_GUEST' as the seed passed into
string_to_fake_mac; modify the code around fritzbox_mac and guest_mac so
string_to_fake_mac receives either the normalized MAC or the sentinel, not the
original raw value.

@jokob-sk jokob-sk merged commit cc507f2 into main Apr 10, 2026
7 checks passed
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.

1 participant