-
Notifications
You must be signed in to change notification settings - Fork 109
fix(dashboard): scope reliability endpoints by projectId #1970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1595,6 +1595,8 @@ export function createServer(store: TaskStore, options?: ServerOptions): ReturnT | |
| }); | ||
|
|
||
| app.get("/api/health/reliability", async (req, res) => { | ||
| const projectId = getProjectIdFromRequest(req); | ||
| const scopedStore = projectId ? await getScopedStore(projectId) : store; | ||
|
Comment on lines
1597
to
+1599
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The project's coding convention (AGENTS.md) requires a Context Used: AGENTS.md (source) Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| const rawWindowDays = req.query.windowDays; | ||
| const parsedWindowDays = rawWindowDays === undefined ? 7 : Number.parseInt(String(rawWindowDays), 10); | ||
|
|
||
|
|
@@ -1606,7 +1608,7 @@ export function createServer(store: TaskStore, options?: ServerOptions): ReturnT | |
| return; | ||
| } | ||
|
|
||
| const settings = await store.getSettings(); | ||
| const settings = await scopedStore.getSettings(); | ||
| const resetAt = typeof settings.reliabilityStatsResetAt === "string" ? settings.reliabilityStatsResetAt : null; | ||
|
|
||
| const nowMs = Date.now(); | ||
|
|
@@ -1617,11 +1619,11 @@ export function createServer(store: TaskStore, options?: ServerOptions): ReturnT | |
| const endIso = new Date(nowMs).toISOString(); | ||
|
|
||
| const [runAuditEvents, enteredByDay, bouncedByDay, durationEvents, mergedTaskIds] = await Promise.all([ | ||
| Promise.resolve(store.getRunAuditEvents({ startTime: startIso, endTime: endIso, limit: 50_000 })), | ||
| store.getTaskMovedCountsByDay({ since: startIso, until: endIso, toColumn: "in-review" }), | ||
| store.getTaskMovedCountsByDay({ since: startIso, until: endIso, fromColumn: "in-review", toColumn: "in-progress" }), | ||
| store.getInReviewDurationEvents({ since: startIso, until: endIso }), | ||
| store.getTaskMergedTaskIds({ since: startIso, until: endIso }), | ||
| Promise.resolve(scopedStore.getRunAuditEvents({ startTime: startIso, endTime: endIso, limit: 50_000 })), | ||
| scopedStore.getTaskMovedCountsByDay({ since: startIso, until: endIso, toColumn: "in-review" }), | ||
| scopedStore.getTaskMovedCountsByDay({ since: startIso, until: endIso, fromColumn: "in-review", toColumn: "in-progress" }), | ||
| scopedStore.getInReviewDurationEvents({ since: startIso, until: endIso }), | ||
| scopedStore.getTaskMergedTaskIds({ since: startIso, until: endIso }), | ||
| ]); | ||
|
|
||
| const postMergeByDay = postMergeAuditFailuresPerDay(runAuditEvents, effectiveStartMs, nowMs); | ||
|
|
@@ -1698,9 +1700,11 @@ export function createServer(store: TaskStore, options?: ServerOptions): ReturnT | |
| }); | ||
| }); | ||
|
|
||
| app.post("/api/health/reliability/reset", async (_req, res) => { | ||
| app.post("/api/health/reliability/reset", async (req, res) => { | ||
| const projectId = getProjectIdFromRequest(req); | ||
| const scopedStore = projectId ? await getScopedStore(projectId) : store; | ||
|
Comment on lines
+1703
to
+1705
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The reset endpoint has the identical problem: |
||
| const resetAt = new Date().toISOString(); | ||
| await store.updateSettings({ reliabilityStatsResetAt: resetAt }); | ||
| await scopedStore.updateSettings({ reliabilityStatsResetAt: resetAt }); | ||
| res.json({ resetAt }); | ||
| }); | ||
|
Comment on lines
+1703
to
1709
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
AGENTS.md requires a changeset under Context Used: AGENTS.md (source) Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getScopedStorerejection in GET handlerBoth the GET and POST endpoints call
await getScopedStore(projectId)without wrapping it in try/catch. If store resolution fails for an unknown or misconfiguredprojectId(e.g.resolveScopedStorethrows), Express 4 won't automatically propagate the async rejection to the error handler — the request will hang without a response. Compare with/api/engine/start(lines 1578–1594) and the terminal WebSocket handler (lines 2059–2077), both of which wrapgetScopedStore/resolveScopedStorein try/catch and return a structured error response. The same guard is needed here so callers receive a500JSON response rather than a stalled connection.