wavetermdev/waveterm · error
error updating workspace: %w
Error message
error updating workspace: %w
What it means
WorkspaceService.UpdateWorkspace applies name/icon/color changes via wcore.UpdateWorkspace and wraps failures with this error. It returns nil,nil when nothing changed (updated=false). Failures usually come from an unknown workspaceId or invalid field values.
Source
Thrown at pkg/service/workspaceservice/workspaceservice.go:49
func (svc *WorkspaceService) CreateWorkspace(ctx context.Context, name string, icon string, color string, applyDefaults bool) (string, error) {
newWS, err := wcore.CreateWorkspace(ctx, name, icon, color, applyDefaults, false)
if err != nil {
return "", fmt.Errorf("error creating workspace: %w", err)
}
return newWS.OID, nil
}
func (svc *WorkspaceService) UpdateWorkspace_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
ArgNames: []string{"ctx", "workspaceId", "name", "icon", "color", "applyDefaults"},
}
}
func (svc *WorkspaceService) UpdateWorkspace(ctx context.Context, workspaceId string, name string, icon string, color string, applyDefaults bool) (waveobj.UpdatesRtnType, error) {
ctx = waveobj.ContextWithUpdates(ctx)
_, updated, err := wcore.UpdateWorkspace(ctx, workspaceId, name, icon, color, applyDefaults)
if err != nil {
return nil, fmt.Errorf("error updating workspace: %w", err)
}
if !updated {
return nil, nil
}
wps.Broker.Publish(wps.WaveEvent{
Event: wps.Event_WorkspaceUpdate,
})
updates := waveobj.ContextGetUpdatesRtn(ctx)
go func() {
defer func() {
panichandler.PanicHandler("WorkspaceService:UpdateWorkspace:SendUpdateEvents", recover())
}()
wps.Broker.SendUpdateEvents(updates)
}()
return updates, nil
}View on GitHub (pinned to a4447c1563)
Solutions
- Confirm workspaceId exists (GetWorkspace) before updating; if not found, refresh the workspace list
- Validate name/icon/color inputs on the caller side to match wcore's validation rules
- Re-read the current workspace and merge changes instead of blind-overwriting with stale values
- Unwrap the %w error to distinguish not-found from validation vs persistence failures
Example fix
// before
WorkspaceService.UpdateWorkspace(ctx, deletedWsId, "new-name", "terminal", "blue", false)
// after
if _, err := WorkspaceService.GetWorkspace(wsId); err == nil {
WorkspaceService.UpdateWorkspace(ctx, wsId, "new-name", "terminal", "blue", false)
} Defensive patterns
Strategy: validation
Validate before calling
const exists = await WorkspaceService.GetWorkspace(workspaceId).catch(() => null);
if (!exists) throw new Error(`workspace ${workspaceId} no longer exists`);
if (!name || !name.trim()) throw new Error("workspace name required"); Type guard
function workspaceStillExists(ws: waveobj.Workspace | null | undefined, id: string): ws is waveobj.Workspace {
return ws != null && ws.OID === id;
} Try / catch
updates, err := WorkspaceService.UpdateWorkspace(ctx, wsId, name, icon, color, applyDefaults)
if err != nil {
if strings.Contains(err.Error(), "not found") { return refreshWorkspaces() }
return fmt.Errorf("update workspace: %w", err)
}
if updates == nil { /* no changes; skip publish */ } Prevention
- Re-read the workspace before saving edits to avoid overwriting concurrent changes
- Handle the nil-updates (unchanged) return path distinctly from errors
- Refresh workspace list after not-found errors instead of retrying the same id
When it happens
Trigger: UpdateWorkspace called with a workspaceId that does not exist (or was deleted), an invalid/empty name, or malformed icon/color values; the wrapped wcore error is preserved for unwrapping.
Common situations: Editing a workspace that was concurrently deleted in another window; frontend sending stale workspace state after external modification; UI validation gaps letting empty names through; scripts mass-updating workspaces with one bad OID.
Related errors
- error getting workspace: %w
- error deleting workspace: %w
- error getting new workspace: %w
- workspace %s not found: %w
- workspace already deleted %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/bb2e64f2e7c61d94.
Report an issue: GitHub.