{"record":{"id":"ea738c1a336a2cd7","repo":"wavetermdev/waveterm","slug":"error-creating-window-w","errorCode":null,"errorMessage":"error creating window: %w","messagePattern":"error creating window: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/service/windowservice/windowservice.go","lineNumber":48,"sourceCode":"\tctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)\n\tdefer cancelFn()\n\twindow, err := wstore.DBGet[*waveobj.Window](ctx, windowId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting window: %w\", err)\n\t}\n\treturn window, nil\n}\n\nfunc (svc *WindowService) CreateWindow_Meta() tsgenmeta.MethodMeta {\n\treturn tsgenmeta.MethodMeta{\n\t\tArgNames: []string{\"ctx\", \"winSize\", \"workspaceId\"},\n\t}\n}\n\nfunc (svc *WindowService) CreateWindow(ctx context.Context, winSize *waveobj.WinSize, workspaceId string) (*waveobj.Window, error) {\n\twindow, err := wcore.CreateWindow(ctx, winSize, workspaceId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating window: %w\", err)\n\t}\n\treturn window, nil\n}\n\nfunc (svc *WindowService) SetWindowPosAndSize_Meta() tsgenmeta.MethodMeta {\n\treturn tsgenmeta.MethodMeta{\n\t\tDesc:     \"set window position and size\",\n\t\tArgNames: []string{\"ctx\", \"windowId\", \"pos\", \"size\"},\n\t}\n}\n\nfunc (ws *WindowService) SetWindowPosAndSize(ctx context.Context, windowId string, pos *waveobj.Point, size *waveobj.WinSize) (waveobj.UpdatesRtnType, error) {\n\tif pos == nil && size == nil {\n\t\treturn nil, nil\n\t}\n\tctx = waveobj.ContextWithUpdates(ctx)\n\twin, err := wstore.DBMustGet[*waveobj.Window](ctx, windowId)\n\tif err != nil {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/service/windowservice/windowservice.go#L30-L66","documentation":"WindowService.CreateWindow delegates actual window creation to wcore.CreateWindow and wraps any failure with this error. Underlying causes include invalid workspace id, invalid window size, or failures persisting/initializing the new window object in the DB.","triggerScenarios":"CreateWindow called with a workspaceId that does not exist, a nil or out-of-range winSize (zero/negative dimensions), or when wcore's window creation step (object persistence, electron window spawn coordination) fails.","commonSituations":"Frontend creating a window right after a workspace was deleted; passing a stored-but-stale workspace OID; running in a headless/test environment where window creation backend steps are unavailable; invalid persisted window-size config values.","solutions":["Unwrap the %w error to see the underlying wcore/wstore cause and fix the specific step that failed","Validate winSize (non-nil, positive width/height) and confirm workspaceId references an existing workspace before calling","Re-fetch the current workspace list; if the workspace is gone, create/select a valid one first","Retry once only if the underlying error is transient (e.g. DB timeout); not-found/invalid-input errors will not self-heal"],"exampleFix":"// before\nWindowService.CreateWindow(ctx, &waveobj.WinSize{Width: 0, Height: 0}, staleWorkspaceId)\n// after\nws, _ := WorkspaceService.GetWorkspace(validWorkspaceId)\nWindowService.CreateWindow(ctx, &waveobj.WinSize{Width: 1200, Height: 800}, ws.OID)","handlingStrategy":"validation","validationCode":"function validWinSize(s) { return s != null && Number.isFinite(s.Width) && s.Width > 0 && Number.isFinite(s.Height) && s.Height > 0; }\nif (!validWinSize(winSize) || !workspaces.some(ws => ws.OID === workspaceId)) throw new Error(\"invalid window creation input\");","typeGuard":"function isValidWinSize(s: waveobj.WinSize | null | undefined): s is waveobj.WinSize {\n  return s != null && s.Width > 0 && s.Height > 0;\n}","tryCatchPattern":"win, err := WindowService.CreateWindow(ctx, winSize, wsId)\nif err != nil {\n    return fmt.Errorf(\"create window: %w\", err) // inspect wrapped wcore cause\n}","preventionTips":["Validate winSize dimensions are positive numbers before calling","Resolve workspaceId from the current workspace list, not cached state","Only retry creation if the wrapped error is transient (e.g. timeout)"],"tags":["window","workspace","creation"],"backgroundTag":"object-creation-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}