Add the GCP import web API - #36
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 48de5d3. Configure here.
| slog.Error("ImportRun failed", "workspace", id, "run", record.ID, "error", err) | ||
| return | ||
| } | ||
| }() |
There was a problem hiding this comment.
Import run stuck queued after failure
Medium Severity
When CreateImportRun writes a QUEUED record, subsequent errors—either during importRunMessage or early failures within the RunImport goroutine (e.g., before fetch handling)—do not update the record to a terminal FAILED state. This leaves a stale QUEUED record visible to pollers, despite the workspace lock being released and the error being logged.
Reviewed by Cursor Bugbot for commit 48de5d3. Configure here.
| records, err := workspace.ListImportRunRecords(s.workspaceDir(entry.Name())) | ||
| if err != nil { | ||
| return nil, connect.NewError(connect.CodeInternal, err) | ||
| } |
There was a problem hiding this comment.
Recent queries abort on bad record
Low Severity
ListRecentImportQueries walks every directory under the workspace root and returns an internal error if ListImportRunRecords fails for any one of them. A single workspace with a corrupt or unreadable import run record disables recent-query recall for all workspaces, not just the affected one.
Reviewed by Cursor Bugbot for commit 48de5d3. Configure here.


Problem
The web server has no API to start or inspect GCP log imports. Users can only run imports through the CLI.
Solution
Add asynchronous ImportRun APIs with saved progress, shared run exclusion, startup recovery, and recent query recall.
This PR covers the backend only. The import form, progress view, and history UI remain separate work.
Major Changes
Note
Medium Risk
New async import path touches workspace mutation, GCP fetch injection, and shared run locking; misconfiguration or lock bugs could block workspaces or leave stale run state, though behavior is heavily tested.
Overview
Adds asynchronous GCP log import to the web backend so clients can start imports, poll status, and reuse recent query parameters without the CLI.
API & codegen:
WorkspaceServicegainsCreateImportRun,GetImportRun,ListImportRuns, andListRecentImportQueries, with newImportRun/ImportRunStatetypes wired through Go Connect and TypeScript protobuf stubs.Server behavior:
pkg/webapp/import_service.govalidates import requests (project, time range, limit defaulting to 100k), writes a queued run record, and runsworkspace.RunImportin a goroutine via an injectedImportFetcher. Imports share the existing per-workspace run lock with discovery and log/workspace mutations. On web startup, queued/running import runs are marked failed withIMPORT_INTERRUPTED(documented alongside discovery recovery inCLAUDE.md).Tests: Broad coverage for validation, async success/failure/truncation, list ordering, mutual exclusion, startup recovery, and recent-query aggregation (capped at 20).
Reviewed by Cursor Bugbot for commit 48de5d3. Bugbot is set up for automated code reviews on this repo. Configure here.