This repository was archived by the owner on Nov 12, 2026. It is now read-only.
Repository navigation
fix(monitor list): page through the REST list, forward --limit/--offset — HAT-1264 - #26
Merged
Merged
Conversation
`listMonitors` called the versioned `GET /v1/monitors` without `limit` and ignored `meta`, so the command's --limit/--offset only sliced the one page the server chose to return. Once the server pages by default the list would be silently truncated (HAT-1264). - `listMonitors` now sends `limit`/`offset` and follows the paging: pages of at most 1000 (the largest the server accepts; 5000 is a 400), until the requested window is full, the server returns an empty page, or `meta.totalCount` is reached (-1 = unknown pages until empty). The legacy bare-array fallback ignores limit/offset, so the window is applied locally there. - `monitor list` forwards --limit/--offset to the API when no local filter applies; with --kind/--disabled/--sort it fetches the whole list (paged) and windows locally as before. - Unit tests with a paged mock: multi-page windows, totalCount stop, server page cap below ours, unknown total, filter on every page, 403 after the first page is an error not a fallback, legacy window. Live (tenant 109601619518, 135 monitors): --limit 1000 -> 135 (same ids as ts-cef2a8e), --limit 5 --offset 133 -> 2, --match mop -> 12. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: HAT-1264. Found in the HAT-1219 review.
Problem
src/rest/monitor/list-monitors.tscalled the versionedGET /v1/monitorswithoutlimitand ignoredmeta. The command's--limit/--offsetonly sliced, on the client, the one page the server chose to return. The server returns every monitor today (135), so nothing is lost yet; once it pages by default the list is silently truncated, and mop-config'scheck-monitor-collisions.sh --limit 1000andmop observe monitor listwould both miss monitors.Change
listMonitorssendslimit/offsetand follows the paging: pages of at most 1000 (the largest the server accepts;limit=5000is a 400), until the requested window is full, the server returns an empty page, ormeta.totalCountis reached (-1= unknown, pages until an empty page). The legacy bare-array fallback (403 on the version header) ignoreslimit/offset, so the window is applied locally there. A 403 after the first page is an error, not a fallback.monitor listforwards--limit/--offsetto the API when no local filter applies. With--kind/--disabled/--sortit fetches the whole list (paged) and windows locally, as before. The table'sFound Nis the window size on the server path.observeinc/climain has the same code and is unchanged by this.Tests
Paged mock in
list-monitors.test.ts: multi-page window (2345 → 3 calls), stop attotalCountwithout an extra request, a limit larger than a page, window inside the list, offset alone, server page cap below ours, unknown total, filter on every page, 403 after page one, legacy window. Command tests: limit/offset forwarded, default limit forwarded, local window with--kind/--sort.Live (tenant 109601619518, darwin-arm64 build)
monitor list --json --limit 1000ts-cef2a8emonitor list --json--offset 100hintmonitor list --json --limit 5 --offset 13343383174,43383547)monitor list --json --match mop --limit 1000meta.totalCount12)monitor list --json --kind Threshold --limit 3limit=5→ 5 +totalCount135;limit=1000→ 135;limit=5000→ 400; legacy shape ignoreslimit🤖 Generated with Claude Code