wavetermdev/waveterm · error
error creating workspace: %w
Error message
error creating workspace: %w
What it means
WorkspaceService.CreateWorkspace creates a workspace via wcore.CreateWorkspace and wraps failures with this error. wcore validates the name/icon/color inputs and persists a new Workspace object; this error means one of those steps failed (invalid input, duplicate/invalid name handling, or a persistence error).
Source
Thrown at pkg/service/workspaceservice/workspaceservice.go:34
"github.com/wavetermdev/waveterm/pkg/wps"
"github.com/wavetermdev/waveterm/pkg/wstore"
)
const DefaultTimeout = 2 * time.Second
type WorkspaceService struct{}
func (svc *WorkspaceService) CreateWorkspace_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
ArgNames: []string{"ctx", "name", "icon", "color", "applyDefaults"},
ReturnDesc: "workspaceId",
}
}
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, nilView on GitHub (pinned to a4447c1563)
Solutions
- Unwrap the %w error to identify whether it was input validation or persistence that failed
- Ensure name is non-empty and icon/color are valid per wcore's validation (valid icon name and color string) before calling
- Handle persistence errors by checking DB health / retrying transient failures once
- If applying defaults fails, try applyDefaults=false and apply configuration manually to isolate the failing step
Example fix
// before WorkspaceService.CreateWorkspace(ctx, "", "bogus-icon", "#zzz", true) // after WorkspaceService.CreateWorkspace(ctx, "dev", "terminal", "#5d4037", true)
Defensive patterns
Strategy: validation
Validate before calling
function validateWorkspaceInput(name, icon, color) {
if (!name || !name.trim()) throw new Error("workspace name required");
if (!icon || !color) throw new Error("icon and color required");
} Type guard
function isValidWorkspaceCreateInput(i: { name: string; icon: string; color: string }): i is { name: string; icon: string; color: string } {
return i.name.trim().length > 0 && i.icon.length > 0 && /^#[0-9a-fA-F]{3,8}$|^\w+$/.test(i.color);
} Try / catch
oid, err := WorkspaceService.CreateWorkspace(ctx, name, icon, color, applyDefaults)
if err != nil {
return fmt.Errorf("create workspace: %w", err)
} Prevention
- Enforce non-empty name and valid icon/color in the UI before dispatching the RPC
- Reject whitespace-only names client-side
- Distinguish validation vs persistence failures by unwrapping the returned error
When it happens
Trigger: CreateWorkspace called with empty/invalid name, invalid icon or color strings, with an applyDefaults value driving a defaults-application failure, or when the underlying wstore insert of the new Workspace object fails.
Common situations: Frontend allowing empty workspace names through UI validation gaps; scripts calling the RPC directly with ad-hoc color/icon strings; DB errors or concurrent creation conflicts; calls with applyDefaults semantics changed in a newer backend.
Related errors
- error creating window: %w
- Image too large (>5MB)
- Unsupported or invalid image type: ${blob.type}
- Invalid CSS color: ${String(color)}
- Invalid CSS color: ${color}
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/539ecd5c17847751.
Report an issue: GitHub.