{"record":{"id":"2c1536b9cbf039fb","repo":"wavetermdev/waveterm","slug":"error-inserting-workspace-w","errorCode":null,"errorMessage":"error inserting workspace: %w","messagePattern":"error inserting workspace: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wcore/workspace.go","lineNumber":63,"sourceCode":"\t\"rocket\",\n\t\"flask\",\n\t\"paperclip\",\n\t\"chart-line\",\n\t\"graduation-cap\",\n\t\"mug-hot\",\n}\n\nfunc CreateWorkspace(ctx context.Context, name string, icon string, color string, applyDefaults bool, isInitialLaunch bool) (*waveobj.Workspace, error) {\n\tws := &waveobj.Workspace{\n\t\tOID:    uuid.NewString(),\n\t\tTabIds: []string{},\n\t\tName:   \"\",\n\t\tIcon:   \"\",\n\t\tColor:  \"\",\n\t}\n\terr := wstore.DBInsert(ctx, ws)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error inserting workspace: %w\", err)\n\t}\n\t_, err = CreateTab(ctx, ws.OID, \"\", true, isInitialLaunch)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating tab: %w\", err)\n\t}\n\n\twps.Broker.Publish(wps.WaveEvent{\n\t\tEvent: wps.Event_WorkspaceUpdate,\n\t})\n\n\tws, _, err = UpdateWorkspace(ctx, ws.OID, name, icon, color, applyDefaults)\n\treturn ws, err\n}\n\n// Returns updated workspace, whether it was updated, error.\nfunc UpdateWorkspace(ctx context.Context, workspaceId string, name string, icon string, color string, applyDefaults bool) (*waveobj.Workspace, bool, error) {\n\tws, err := GetWorkspace(ctx, workspaceId)\n\tupdated := false","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wcore/workspace.go#L45-L81","documentation":"CreateWorkspace failed while persisting the new workspace object via wstore.DBInsert. The wrapped error (%w) carries the underlying storage failure (SQLite/JSON store write error). Thrown by Wave Terminal's wcore workspace layer when a workspace record cannot be written to the backing store.","triggerScenarios":"Calling CreateWorkspace, EnsureInitialData, or CreateWindow when wstore.DBInsert on the new *waveobj.Workspace fails (DB closed, corrupted store, disk full, permission denied on the data dir).","commonSituations":"Corrupt or locked waveterm database file in the data directory; read-only filesystem; disk quota exceeded; concurrent multi-instance writes to the same store.","solutions":["Inspect the wrapped cause printed with this message to find the storage error","Check disk space and write permissions on the Wave data directory (~/.waveterm)","Quit all Wave instances and back up, then remove/rebuild a corrupted DB file","Retry CreateWorkspace after fixing storage"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Go: check store availability first\nif _, err := os.Stat(wavebase.GetWaveDataDir()); err != nil {\n    return fmt.Errorf(\"wave data dir unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"ws, err := wcore.CreateWorkspace(ctx, \"\", \"\", \"\", false)\nif err != nil {\n    var wrapped error\n    if errors.As(err, &wrapped) { log.Printf(\"cause: %v\", wrapped) }\n    return fmt.Errorf(\"workspace create failed: %w\", err)\n}","preventionTips":["Keep the Wave data directory writable and with free disk space","Run only one Wave instance per data dir","Back up and periodically check DB integrity"],"tags":["go","database","workspace"],"backgroundTag":"database-insert-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}