NetBox integration misses paginated devices (only first page fetched) #687
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#687
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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.
Original GitHub issue: #2149
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/issues/2149
Original created: 2025-12-16T05:17:54Z
Summary
/api/dcim/devices/endpoint to discover devices and perform reconciliation.Code with bug
In
pkg/sync/integrations/netbox/netbox.go, theFetchmethod:The
Reconcilemethod has the same bug:In
pkg/sync/integrations/netbox/types.go, theDeviceResponsestruct includes pagination fields that are never used:Evidence
Failing test
Test script
Test output
Example
Consider a NetBox instance with 75 devices:
"next": "https://netbox.example.com/api/dcim/devices/?offset=50"fetchDevices()once, receives the first page responseNextfield or fetches the second pageWorse scenario - reconciliation with previously discovered devices:
"_deleted": "true"Full context
The NetBox integration is part of ServiceRadar's device discovery system. It pulls device information from NetBox (an IP address management and data center infrastructure management tool) to populate ServiceRadar's device inventory.
The
Fetchmethod is called periodically by the sync service to discover new devices from NetBox. It:/api/dcim/devices/endpointThe
Reconcilemethod is called after sweeps complete to identify devices that no longer exist in NetBox:"_deleted": "true") for devices in ServiceRadar but not in the current NetBox fetchThe bug affects both discovery and reconciliation:
The integration is used by the sync service (
pkg/sync/sync.go) which orchestrates multiple integration sources. NetBox is a common source of truth for network infrastructure, so this bug affects any organization using ServiceRadar with a NetBox instance containing more than 50 devices.External documentation
Why has this bug gone undetected?
This bug has likely gone undetected for several reasons:
Small test deployments: Development and test environments likely have fewer than 50 devices in NetBox, so pagination is never triggered during testing.
No validation of total count: The code logs "devices_discovered" but never compares it against the
Countfield from the API response, which would reveal that only a subset was fetched.Gradual device growth: In production environments, NetBox instances may start with < 50 devices and grow over time. The first 50 devices work correctly, masking the problem until the threshold is crossed.
Reconciliation timing: If reconciliation hasn't run since crossing the 50-device threshold, the incorrect retractions haven't occurred yet. Once they do, they might be attributed to other causes like network issues or configuration changes.
Silent failure mode: The integration doesn't fail or error when pagination is needed - it simply processes fewer devices than expected, which might be mistaken for legitimate filtering or missing data in NetBox.
Recommended fix
Implement pagination by checking the
Nextfield in theDeviceResponseand fetching subsequent pages untilNextis empty:Then update
FetchandReconcileto usefetchAllDevices()instead offetchDevices().