wavetermdev/waveterm · error
error getting workspace: %w
Error message
error getting workspace: %w
What it means
WorkspaceService.GetWorkspace reads a Workspace from wstore by OID with a DefaultTimeout context and wraps DBGet failures with this error. It most commonly means no workspace exists with the given workspaceId, or the DB read timed out/failed.
Source
Thrown at pkg/service/workspaceservice/workspaceservice.go:81
}()
wps.Broker.SendUpdateEvents(updates)
}()
return updates, nil
}
func (svc *WorkspaceService) GetWorkspace_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
ArgNames: []string{"workspaceId"},
ReturnDesc: "workspace",
}
}
func (svc *WorkspaceService) GetWorkspace(workspaceId string) (*waveobj.Workspace, error) {
ctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)
defer cancelFn()
ws, err := wstore.DBGet[*waveobj.Workspace](ctx, workspaceId)
if err != nil {
return nil, fmt.Errorf("error getting workspace: %w", err)
}
return ws, nil
}
func (svc *WorkspaceService) DeleteWorkspace_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
ArgNames: []string{"workspaceId"},
}
}
func (svc *WorkspaceService) DeleteWorkspace(workspaceId string) (waveobj.UpdatesRtnType, string, error) {
ctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)
defer cancelFn()
ctx = waveobj.ContextWithUpdates(ctx)
deleted, claimableWorkspace, err := wcore.DeleteWorkspace(ctx, workspaceId, true)
if claimableWorkspace != "" {
return nil, claimableWorkspace, nil
}View on GitHub (pinned to a4447c1563)
Solutions
- Verify the workspaceId against the current workspace list before calling; refresh if it is stale
- Treat not-found as terminal — do not retry with the same id; fall back to fetching all workspaces
- Unwrap the %w error: if it is a timeout, check DB health and consider increasing retry backoff (timeout itself is fixed by DefaultTimeout)
- If ids come from persisted config/state, validate and prune stale references at load time
Example fix
// before ws, err := WorkspaceService.GetWorkspace(oldConfigWsId) // stale id // after workspaces := GetAllWorkspaces() wsId := pickValidId(workspaces, oldConfigWsId)
Defensive patterns
Strategy: try-catch
Validate before calling
const wss = await WorkspaceService.GetAllWorkspaces();
if (!wss.some(w => w.OID === workspaceId)) throw new Error(`workspace ${workspaceId} not in current list`); Type guard
function isWorkspaceWithId(w: waveobj.Workspace | undefined, id: string): w is waveobj.Workspace {
return w != null && w.OID === id;
} Try / catch
ws, err := WorkspaceService.GetWorkspace(workspaceId)
if err != nil {
var nf *wstore.NotFoundError
if errors.As(err, &nf) { return fallbackToWorkspaceList() }
return fmt.Errorf("get workspace %s: %w", workspaceId, err)
} Prevention
- Prune stale workspace OIDs from persisted config/state at load time
- Use GetAllWorkspaces as a fallback when a specific id is missing
- Do not cache workspace objects across sessions; always re-resolve ids
When it happens
Trigger: GetWorkspace called with a deleted workspace's OID, a malformed/empty id, an id pointing to a non-workspace object, or when the wstore read exceeds DefaultTimeout or errors.
Common situations: Frontend restoring state referencing workspaces removed since last session; race after DeleteWorkspace; hardcoded OIDs in tests/scripts; slow disk or large DB causing the timeout to fire.
Related errors
- error getting block: %w
- error getting window: %w
- error updating workspace: %w
- error deleting workspace: %w
- error getting tab: %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/e27eecfe88d939ab.
Report an issue: GitHub.