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

  1. Confirm workspaceId exists (GetWorkspace) before updating; if not found, refresh the workspace list
  2. Validate name/icon/color inputs on the caller side to match wcore's validation rules
  3. Re-read the current workspace and merge changes instead of blind-overwriting with stale values
  4. 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

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


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/bb2e64f2e7c61d94. Report an issue: GitHub.