Repository navigation
Conversation
The automation unknown_entity_references repair scans every value inside a service call's `data` payload and flags any `domain.object_id`-shaped string as a referenced entity. The only existing guard skips this for the notify domain's own `data.target` field. This misses a common case: a third-party "fan-out" action (e.g. notifier_hub.send) that accepts a list of legacy notify.* service names under an arbitrary data key (e.g. data.notify). Those strings are service identifiers, not entity references, so they get wrongly reported as unknown entities. Genuine references to notify domain entities are always expressed via target.entity_id, which is handled separately and unaffected by this change. Filter out notify.* matches found via the generic data-payload scan, regardless of the calling service or key name.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds filtering so ChangesNotify Service Reference Filtering
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
custom_components/spook/ectoplasms/automation/repairs/unknown_entity_references.py (1)
262-274: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winNotify filter not applied when
dataitself is a bare string.The new filter is only wired into the dict-item loop (lines 270-274). When
config["data"]is itself a plain string matchingENTITY_ID_PATTERN(line 264-266, viaextract_entities_from_value), a value likedata: "notify.old_tablet"would still be flagged as an entity, since_filter_out_notify_service_referencesis never applied to that branch's result. This is the same false-positive class the PR is fixing, just for the "data value as a raw string" shape rather than "data value as a dict of key→value(s)".🐛 Proposed fix to also filter the string-branch result
if isinstance(data_value, str): # data field is a template string itself - entities.update(await extract_entities_from_value(hass, data_value)) + entities.update( + _filter_out_notify_service_references( + await extract_entities_from_value(hass, data_value) + ) + )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@custom_components/spook/ectoplasms/automation/repairs/unknown_entity_references.py` around lines 262 - 274, The notify-service filter is only applied in the dict-handling branch of the data processing logic, so bare string values in config["data"] can still produce false positives. Update the data handling in unknown_entity_references.py so the string path that calls extract_entities_from_value also passes its result through _filter_out_notify_service_references, matching the behavior already used for the dict-item loop. Keep the fix localized to the existing data branch in the same helper that processes config["data"].
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@custom_components/spook/ectoplasms/automation/repairs/unknown_entity_references.py`:
- Around line 262-274: The notify-service filter is only applied in the
dict-handling branch of the data processing logic, so bare string values in
config["data"] can still produce false positives. Update the data handling in
unknown_entity_references.py so the string path that calls
extract_entities_from_value also passes its result through
_filter_out_notify_service_references, matching the behavior already used for
the dict-item loop. Keep the fix localized to the existing data branch in the
same helper that processes config["data"].
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9a2d958e-c24d-49b0-b1c1-f8c3f930a934
📒 Files selected for processing (2)
custom_components/spook/ectoplasms/automation/repairs/unknown_entity_references.pytests/ectoplasms/automation/repairs/test_unknown_entity_references.py
The notify-service filter introduced to fix the dict-shaped data branch was missing from the string-shaped data branch, so a literal notify.* service name assigned directly to data (as opposed to nested under a dict key) was still incorrectly flagged as an unknown entity. Found by CodeRabbit's automated review on the PR.
|
|
Any idea when this fix enters a release 🙏 |
|
superseed by #1440 |



Summary
Fixes #1338.
The
automation_unknown_entity_referencesrepair scans every value inside a service call'sdatapayload and flags anydomain.object_id-shaped string as a referenced entity. The only existing guard (_should_skip_service_data_value) only skips this for thenotifydomain's owndata.targetfield, when the calling service itself starts withnotify..This misses a common pattern: a third-party "fan-out notifier" action (e.g.
notifier_hub.send) that accepts a list of legacynotify.*service names under an arbitrarydatakey (e.g.data.notify). Those strings are legacy notify service identifiers, not entity references, but get wrongly flagged as unknown entities since neither the calling service nor the key matches the existing guard.A genuine reference to a
notifydomain entity is always expressed viatarget.entity_id, which is handled separately by_extract_entities_from_targetand is completely unaffected by this change.Change
_filter_out_notify_service_references(): strips anynotify.*match found via the genericdata-payload scan, regardless of key name or calling service._extract_entities_from_service_data()right after the existingextract_entities_from_value()call.This is intentionally narrow/surgical - it only changes behavior for
notify.*-shaped values discovered insidedata, and leavestarget.entity_id/target.device_idextraction (and all other entity detection) untouched.Tests
Added two tests to
tests/ectoplasms/automation/repairs/test_unknown_entity_references.py:test_third_party_service_data_notify_list_is_not_an_entity_reference- reproduces the real-world false positive (anotifier_hub.send-style action withdata.notify: [...]).test_notify_target_entity_id_is_still_detected- regression guard confirming a genuinetarget.entity_id: "notify.xyz"reference is still correctly detected/flagged when unknown, so the fix doesn't overreach.All existing tests in the file (48 total before, 50 after) continue to pass.
Verification