fix(api): finish moving investigation queries to the unified schema - #191
Merged
Merged
Conversation
|
Deployment failed for project dataing with the following error: Learn More: https://vercel.com/bordumbs-projects?upgradeToPro=build-rate-limit |
bordumb
force-pushed
the
claude/practical-chaum-bbb68b
branch
from
September 27, 2026 20:18
5aeb687 to
1c8a7cf
Compare
Follow-up to #183. These call sites still read columns that 013_unified_investigation.sql dropped and failed at runtime: - Dashboard: get_dashboard_stats filtered on completed_at and on statuses the generated status column never takes. Migration 036 adds investigations.completed_at, stamped by a trigger the first time outcome is set; active = no outcome, completed today = completed_at today. list_investigations now returns summaries from the alert JSONB (primary dataset, metric display name or anomaly type, severity), "unknown" for imported replays. The frontend called /dashboard/stats without /api/v1, read camelCase keys the API never sends and fell back to mock numbers; it now uses the generated client and shows "—" and an error on failure. - RBAC: PermissionService matched datasource grants on investigations.data_source_id, so every access check raised. It now compares with alert->>'datasource_id'. - Fix feedback export: the investigation context read investigations.issue_id; it now names the issue from issue_investigation_runs. - EE runbooks: generation from an issue read issues.resolution/metadata and investigations.issue_id/synthesis; it now uses resolution_note, issue_labels and the latest linked investigation's outcome, and the route records that investigation. Runbook responses also decode JSONB text, which failed validation on every runbook route. Integration tests run against the migrated schema via migrated_db. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
bordumb
force-pushed
the
claude/practical-chaum-bbb68b-schema-followups
branch
from
September 27, 2026 21:53
af05a59 to
ec36ee8
Compare
|
Deployment failed for project dataing-docs with the following error: Learn More: https://vercel.com/bordumbs-projects?upgradeToPro=build-rate-limit |
|
Deployment failed for project dataing-app with the following error: Learn More: https://vercel.com/bordumbs-projects?upgradeToPro=build-rate-limit |
github-actions Bot
pushed a commit
that referenced
this pull request
Sep 27, 2026
## [1.24.4](v1.24.3...v1.24.4) (2026-09-27) ### Bug Fixes * **api:** finish moving investigation queries to the unified schema ([#191](#191)) ([fcffde5](fcffde5))
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.
Summary
Follow-up to #183. These call sites still read columns that
013_unified_investigation.sqldropped, and they failed at runtime:get_dashboard_statsfiltered oncompleted_atand on status values the generatedstatuscolumn never takes.036addsinvestigations.completed_at, set by a trigger the first timeoutcomeis set. "Completed Today" countscompleted_attoday, and "Active" counts investigations with no outcome. The migration is re-runnable and has noBEGIN/COMMIT.list_investigationsnow returns summaries from the alert JSONB: primary dataset, metric display name (else anomaly type) and severity. Imported replays show "unknown" instead of crashingGET /dashboard/.fetchDashboardStatsrequested/dashboard/statswithout/api/v1, so it always failed and fell back to mock 3/7/2 numbers. It also read camelCase keys the API never sends. It now uses the generated client and maps the response, andDashboardStatsCardsshows "—" and an error when loading fails.PermissionServicejoined grants oninvestigations.data_source_id. The whole EXISTS/UNION query failed, so everycan_access_investigationcall raised. It now comparespg.data_source_id::textwithalert->>'datasource_id'(4 places).investigations.issue_id. The newFixFeedbackService.investigation_context()names the latest issue fromissue_investigation_runs, and leavesissue_idout when there's none.issues.resolution/metadataandinvestigations.issue_id/synthesis. It now usesresolution_note,issue_labelsand the latest linked investigation'soutcome, and the route records that investigation increated_from_investigation_id._row_to_responsenow decodes JSONB text.AppDatabasehas no JSONB codec, so every runbook route failed list validation before this.Not changed: the issue route's AnomalyAlert was already fixed by #159. Sharing one issue→alert helper between CE and EE is deferred (flow
fn-16.21).Tests
Each test was written first and failed for the expected reason before the fix, all against the migrated schema via
migrated_db:test_investigation_completed_at.pyapi/test_dashboard.pycore/test_permission_service.pytest_fix_feedback_export_context.pyapi/test_runbook_from_issue.pylib/api/dashboard.test.ts,features/dashboard/dashboard-stats.test.tsxBackend CI only runs on PRs into main, so this stacked PR gets none. Verified locally on this branch (#183 + this commit):
The same change merged onto current main was also green except for #150's approvals
POLICYentries, which #183 has to drop.Merge notes
("POST", "/approvals/...")entries also have to come out oftest_route_authorization.py.provide_link_feedback, separately from this PR. This PR'srunbooks.pyhunks merge cleanly with it.json.dumps, so they'll need converting when that lands. The new source reads accept both text and decoded values.🤖 Generated with Claude Code