{"record":{"id":"9fac557f4e2e3c00","repo":"wavetermdev/waveterm","slug":"error-getting-window-w-9fac55","errorCode":null,"errorMessage":"error getting window: %w","messagePattern":"error getting window: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wcore/layout.go","lineNumber":161,"sourceCode":"\nfunc BootstrapStarterLayout(ctx context.Context) error {\n\tctx, cancelFn := context.WithTimeout(ctx, 2*time.Second)\n\tdefer cancelFn()\n\tclient, err := wstore.DBGetSingleton[*waveobj.Client](ctx)\n\tif err != nil {\n\t\tlog.Printf(\"unable to find client: %v\\n\", err)\n\t\treturn fmt.Errorf(\"unable to find client: %w\", err)\n\t}\n\n\tif len(client.WindowIds) < 1 {\n\t\treturn fmt.Errorf(\"error bootstrapping layout, no windows exist\")\n\t}\n\n\twindowId := client.WindowIds[0]\n\n\twindow, err := wstore.DBMustGet[*waveobj.Window](ctx, windowId)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting window: %w\", err)\n\t}\n\n\tworkspace, err := wstore.DBMustGet[*waveobj.Workspace](ctx, window.WorkspaceId)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting workspace: %w\", err)\n\t}\n\n\ttabId := workspace.ActiveTabId\n\n\tstarterLayout := GetStarterLayout()\n\terr = ApplyPortableLayout(ctx, tabId, starterLayout, false)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error applying starter layout: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wcore/layout.go#L143-L179","documentation":"After selecting the first window id from the client, BootstrapStarterLayout does DBMustGet[*waveobj.Window]. This error wraps any failure — most commonly the window record missing from the store despite its id being referenced in client.WindowIds.","triggerScenarios":"client.WindowIds[0] refers to a window id whose record was deleted, was never persisted, or the wstore read fails; also fires on the 2s context timeout of BootstrapStarterLayout.","commonSituations":"Stale window id left in the client record after a crash or manual DB edit; partial startup where window creation failed after the client was updated; corrupted wave store.","solutions":["Inspect the wrapped error: ErrNotFound means a dangling WindowIds entry — remove it or recreate the window","Re-verify window creation completed and persisted before bootstrapping","Check wave store integrity; restore or delete the corrupted DB so startup re-initializes","Watch for the 2s ctx timeout on slow filesystems"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for _, wid := range client.WindowIds {\n    if _, err := wstore.DBGet[*waveobj.Window](ctx, wid); err != nil {\n        // dangling window reference — prune or recreate before bootstrap\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := wcore.BootstrapStarterLayout(ctx); err != nil {\n    if strings.Contains(err.Error(), \"error getting window\") {\n        if errors.Is(err, wstore.ErrNotFound) {\n            // remove stale WindowIds entry and recreate window\n        }\n    }\n}","preventionTips":["Treat WindowIds as soft references; validate before use","Avoid manual edits to the wave store DB","Watch the 2s context deadline on slow filesystems"],"tags":["waveterm","wstore","window","dangling-reference"],"backgroundTag":"record-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}