Skip to content

fix(browse): brief site list to avoid count-annotation timeout (0.8.1) - #63

Merged
lance0 merged 1 commit into
masterfrom
fix/sites-browse-brief
Jun 22, 2026
Merged

lance0 merged 1 commit into
masterfrom
fix/sites-browse-brief

Conversation

@lance0

@lance0 lance0 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Problem

Browsing sites in the TUI times out on a real instance:

error: sending request to NetBox: ... /api/dcim/sites/?limit=100&offset=0: operation timed out

…while the nav count for sites shows up fine. That split is the tell.

Root cause

NetBox's full site list serializer attaches per-site aggregate counts (device_count, prefix_count, rack_count, vlan_count, circuit_count, …), each a subquery over a large table. The count query (limit=1) is cheap, but serializing a full page of sites runs those subqueries per row. Measured against a live 149-site instance:

Request Time
?limit=1 (nav count) 0.19s ✓
?limit=100 (full list) >120s — timed out ✗
?limit=100&brief=true 0.29s ✓

Raising timeout_secs doesn't help (it's >2 minutes). Every other browse kind (devices, racks, prefixes, IPs, vlans, vrfs, route-targets) lists in 0.2–0.8s at full — sites is the only heavy one.

Fix

Request NetBox's brief representation for the site browse only. Brief omits the counts and returns id/url/name/slug — and the site browse index only renders name + slug, so there's no column loss. Opening a site still fetches the full object for its detail view. Other kinds are untouched (they're already fast and keep their full columns).

~400× faster (0.3s vs >120s) on the affected instance.

Verification

  • New unit test site_browse_requests_brief_to_skip_count_annotations (wiremock matches only when brief=true is sent).
  • Confirmed against the live instance: all 149 sites' brief payloads carry the required id/url/name/slug, so they deserialize cleanly.
  • Gate green: fmt, clippy (all-features), tests.

Bumps 0.8.0 → 0.8.1.

…n timeout

NetBox's full site list serializer attaches per-site aggregate counts
(device/prefix/rack/vlan/circuit), each a subquery over a large table. On a
sizable instance that's slow enough to exceed the request timeout — observed on
a real instance: GET /api/dcim/sites/?limit=100 took >120s, while the nav count
(limit=1) and every other browse kind returned in <1s. The full list was
effectively unusable.

The site browse only renders name + slug, both present in NetBox's `brief`
representation, which omits the counts. Request brief=true for the site browse:
~400x faster in testing (0.3s vs >120s), with no column loss. Opening a site
still fetches the full object for its detail view. Site is the only browse kind
heavy enough to need this; the rest list fine at full and keep their columns.

Bump 0.8.0 -> 0.8.1.
@lance0
lance0 merged commit f984fe6 into master Jun 22, 2026
4 checks passed
@lance0
lance0 deleted the fix/sites-browse-brief branch June 22, 2026 17:04
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