feat(dashboard): add revision history and restore commands#936
feat(dashboard): add revision history and restore commands#936MathurAditya724 wants to merge 3 commits intomainfrom
Conversation
Add `sentry dashboard revisions` to list revision history for a dashboard and `sentry dashboard restore` to revert to a previous revision. - New API functions: listDashboardRevisionsPaginated, restoreDashboardRevision - DashboardRevision type with Zod schema - Full cursor-based pagination support for revisions list - `history` alias for `revisions` subcommand Fixes #935
|
|
fix-ci: attempt 1 — |
|
fix-ci: added |
Codecov Results 📊✅ 6836 passed | Total: 6836 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ❌ Patch coverage is 30.12%. Project has 14211 uncovered lines. Files with missing lines (3)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 77.02% 76.70% -0.32%
==========================================
Files 317 319 +2
Lines 60609 60997 +388
Branches 0 0 —
==========================================
+ Hits 46684 46786 +102
- Misses 13925 14211 +286
- Partials 0 0 —Generated by Codecov Action |
|
all CI checks green — lint, typecheck, unit tests, e2e, binary builds, and docs all pass. self-review looks clean: the two new commands follow existing dashboard command patterns, pagination and error handling are consistent, and completion sets are updated. marked ready for review. |
| { method: "POST", schema: DashboardDetailSchema } | ||
| ); |
There was a problem hiding this comment.
Bug: The pagination logic for the revisions command incorrectly saves the cursor when a --limit is met mid-page, causing items to be skipped on subsequent paginated requests.
Severity: HIGH
Suggested Fix
Implement a "bookmark" cursor mechanism similar to the sentry dashboard list command. This involves encoding the ID of the last processed item into the cursor, allowing the next fetch to resume from the exact point within a server-side page rather than skipping to the next one.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/lib/api/dashboards.ts#L230-L231
Potential issue: The manual pagination loop in the `sentry dashboard revisions` command
incorrectly handles pagination when a user-specified `--limit` is reached mid-page. The
code fetches full pages from the API, but if the limit is met partway through a page,
the cursor saved for the next run points to the start of the *next* API page. This
causes all remaining items from the current, partially-processed page to be skipped
entirely, leading to data loss for the user.
Also affects:
src/commands/dashboard/revisions.ts
There was a problem hiding this comment.
not a real issue here. the bookmark cursor in dashboard list exists for client-side glob filtering, where items are skipped within a page. revisions has no client-side filtering — it sets perPage = Math.min(limit, API_MAX_PER_PAGE), so when limit <= 100 (the default is 25), the server page size matches the requested limit exactly and there's no mid-page break. for limit > 100 the behavior matches issue list and other commands that auto-paginate without bookmarks.
Add
sentry dashboard revisionsandsentry dashboard restorecommands to support dashboard revision history.revisionslists saved revisions for a dashboard with cursor-based paginationrestorereverts a dashboard to a specific revision by IDhistoryalias available forrevisionsCloses #935