adding tests for sweep compiler #2702
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2702
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2702/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub pull request.
Original GitHub pull request: #2357
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2357
Original created: 2026-01-18T20:19:18Z
Original updated: 2026-01-18T20:29:28Z
Original head: carverauto/serviceradar:bug/agent-not-getting-sweep-config
Original base: staging
Original merged: 2026-01-18T20:29:27Z by @mfreeman451
User description
IMPORTANT: Please sign the Developer Certificate of Origin
Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include
a DCO sign-off statement indicating the DCO acceptance in one commit message. Here
is an example DCO Signed-off-by line in a commit message:
Describe your changes
Issue ticket number and link
Code checklist before requesting a review
PR Type
Bug fix, Tests, Enhancement
Description
Fix sweep group targeting rules not persisting through UI save/edit cycle
Resolve agent partition from registry instead of hardcoding "default"
Add comprehensive integration tests for sweep config compilation
Improve debugging with extensive logging throughout sweep config flow
Diagram Walkthrough
File Walkthrough
1 files
Add debug logging to sweep group loading2 files
Resolve partition from agent registry dynamicallyFix criteria parsing and add debug logging3 files
Add partition resolution and sweep config testsAdd comprehensive sweep targeting integration testsAdd targeting rules round-trip persistence tests3 files
Document sweep targeting rules bug analysisAdd sweep config requirements and scenariosDocument investigation and fix tasksImported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2357#issuecomment-3765704858
Original created: 2026-01-18T20:19:52Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
Sensitive data in logs
Description: New
Logger.debug/Logger.warningstatements log potentially sensitive operational data(e.g.,
group.target_criteria,static_targets, agent IDs, partitions, and resolvedIP/target details) using
inspect/1, which could expose internal network ranges, devicetargeting rules, and identifiers in application logs (also present in
elixir/serviceradar_core/lib/serviceradar/agent_config/compilers/sweep_compiler.exlines132-146 and
elixir/serviceradar_core/lib/serviceradar/edge/agent_config_generator.exlines299-351).
index.ex [166-2390]
Referred Code
🎫 No ticket provided
Codebase context is not defined
Follow the guide to enable codebase context checks.
Generic: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
Status: Passed
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status: Passed
Generic: Secure Error Handling
Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.
Status: Passed
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status:
Missing user context: New logs around sweep group edits/saves do not include an acting user identifier (or
equivalent audit context), reducing the ability to reliably reconstruct who performed the
critical configuration change.
Referred Code
Generic: Secure Logging Practices
Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.
Status:
Sensitive data in logs: Newly added debug logs
inspect/1fulltarget_criteriaand full submittedparams, which caninclude network targets/IP ranges and other sensitive operational data, and are emitted as
unstructured strings.
Referred Code
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status:
Registry trust boundary:
get_agent_partition/1trustsAgentRegistry.lookup/1metadata (partition_id) withoutvisible validation/authorization checks in the diff, which may be safe if the registry is
internal-only but cannot be confirmed from the shown changes.
Referred Code
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2357#issuecomment-3765706226
Original created: 2026-01-18T20:21:19Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Invalidate cache in setup
In
sweep_targeting_integration_test.exs, addConfigServer.invalidate(:sweep)tothe
setupblock to ensure test isolation and prevent failures due to stalecached configurations.
elixir/serviceradar_core/test/serviceradar/sweep_jobs/sweep_targeting_integration_test.exs [27-37]
Suggestion importance[1-10]: 8
__
Why: This is a critical improvement for test stability. Adding
ConfigServer.invalidate(:sweep)to thesetupblock ensures each test runs in isolation, preventing flaky failures caused by cached data from previous tests.Improve agent partition lookup robustness
In
get_agent_partition, modify thecasestatement to handle multiple agentregistrations by changing the pattern match from
[{_pid, metadata}]to[{_pid,metadata} | _].elixir/serviceradar_core/lib/serviceradar/edge/agent_config_generator.ex [331-352]
Suggestion importance[1-10]: 6
__
Why: The suggestion correctly identifies a potential edge case where multiple agent registrations would cause the partition lookup to fail, and proposes a robust fix by handling a non-empty list instead of a single-element list.
Align UI with backend validation
In
criteria_to_rules/1, remove the logic for handling multiple operators perfield (
map_size(spec) > 1) to align with backend validation, which rejects thisformat.
web-ng/lib/serviceradar_web_ng_web/live/settings/networks_live/index.ex [2350-2393]
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies that the PR adds UI logic for a multi-operator case that is explicitly rejected by backend validation, and proposes removing it to prevent an inconsistent and confusing user experience.