Repository navigation
fix(dashboard): read every DynamoDB page; fail closed on a failed page (#1421) - #1425
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…socket processor (#1421)
scttfrdmn
force-pushed
the
fix/1421-dashboard-watches-pagination
branch
from
October 29, 2026 19:21
cc38964 to
2b8f9f3
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1421
What
The dashboard read one DynamoDB page (at most 1 MB) per Query/Scan and showed it as the complete list.
lambda/dashboard-api/paging.goaddsqueryAll,queryUpTo(bounded with atruncatedsignal),scanAllandscanFirst, modelled on lagotto#181'squeryAll. Each followsLastEvaluatedKeyto the end and returns an error, never a partial result, when any page fails.Call sites fixed:
GET /api/watches(handleListWatches)queryAll+ per-itemuser_id == callercheck (fail-closed, ashandleGetWatch)GET /api/watches/history(handleWatchHistory)Limit 100, no signalqueryUpToacross pages,"truncated": truewhen older matches exist, per-item ownership (MatchInfo.UserID,json:"-")GET /api/cost-historyqueryAll+ ownership checkGET /api/sweepspersonalLimit 200(counted BEFORE theuser_idfilter, so >200 sweeps in the table = arbitrary subset)scanAll+ ownership checkGET /api/sweeps?team_id=teamsuccess: truequeryAll; failure is a 500 (CHANGELOG: Changed)GET /teams(handleListMyTeams)queryAll+member_arn == callerGET /teams/{id}membersLimit 500queryAll+team_idcheckDELETE /teams/{id}scanFirstacross pages; scan error is an errordashboard-websocket-processorgetActiveConnectionsdynamodb.ScanAPIClientLeft single-page with a justification comment:
auth.golookupCliIamArnByEmail, which uses only the first match, and a Query without a FilterExpression returns an empty page only when nothing matches.Audited and already correct:
cost-history-collectorlistAllUsers(paginates).dashboard-websocketmakes no Query/Scan calls.No IAM change: same actions on the same tables.
Gates (each watched failing against a compiling revert)
paging_test.gowire fake (pagedDynamo) serves 3 pages (the middle one empty, as filtered Scans often are) and can fail a page with a non-retryable error. For each handler: all items across 3 pages, a failed page is a 500 with no list, and a foreign or ownerless record on page 3 is not returned.TestDashboardDynamoCallsArePaginated: an AST scan of the package's non-test sources. Any direct.Query(/.Scan(call must carry a// single-page:comment above it. The test fails if discovery finds no calls at all.TestWatchHistoryBoundIsReportedAsTruncated: 121 matches give 100 andtruncated; exactly 100 give 100 and notruncated.connections_test.go, 3 pages read and a failed page is an error.Reverts and the gates that failed:
origin/maincopy of each ofcost_history.go,sweeps.go,teams.go,slack_oauth.go,auth.go: that file's handler tests and/or the AST gate failedhandleListWatches/handleWatchHistoryback to a singleclient.Query: their tests + AST gate failedif false): the matching ownership test failedTruncatedforced false: truncated test failedmake check,make lint(0 issues, 10 modules) andsemgrep scan --config=auto --error .all pass.Deploy
After release, redeploy
dashboard-apianddashboard-websocket-processorfrom the release tag, using each function'sdeploy.shfrom a checkout of the tag. No IAM or table changes.Note: the personal sweeps listing now scans the entire
spawn-sweep-orchestrationtable on each request, where before it read one 200-item page. That is correct but costs O(table). The table has auser_id-created_at-index(scripts/setup-sweep-dynamodb.sh), so a Query on it would be cheaper. That needs an IAM grant on the index, so it is left as a follow-up.