{"record":{"id":"45103ff7c3d117ea","repo":"wavetermdev/waveterm","slug":"error-creating-window-w-45103f","errorCode":null,"errorMessage":"error creating window: %w","messagePattern":"error creating window: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wcore/wcore.go","lineNumber":83,"sourceCode":"\t\tCheckAndFixWindow(ctx, client.WindowIds[0])\n\t\treturn firstLaunch, nil\n\t}\n\tif len(client.WindowIds) > 0 {\n\t\tlog.Println(\"client has windows\")\n\t\treturn firstLaunch, nil\n\t}\n\twsId := \"\"\n\tif firstLaunch {\n\t\tlog.Println(\"client has no windows and first launch, creating starter workspace\")\n\t\tstarterWs, err := CreateWorkspace(ctx, \"Starter workspace\", \"custom@wave-logo-solid\", \"#58C142\", false, true)\n\t\tif err != nil {\n\t\t\treturn firstLaunch, fmt.Errorf(\"error creating starter workspace: %w\", err)\n\t\t}\n\t\twsId = starterWs.OID\n\t}\n\t_, err = CreateWindow(ctx, nil, wsId)\n\tif err != nil {\n\t\treturn firstLaunch, fmt.Errorf(\"error creating window: %w\", err)\n\t}\n\treturn firstLaunch, nil\n}\n\nfunc CreateClient(ctx context.Context) (*waveobj.Client, error) {\n\tclient := &waveobj.Client{\n\t\tOID:       uuid.NewString(),\n\t\tWindowIds: []string{},\n\t}\n\terr := wstore.DBInsert(ctx, client)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error inserting client: %w\", err)\n\t}\n\treturn client, nil\n}\n\nfunc GetClientData(ctx context.Context) (*waveobj.Client, error) {\n\tclientData, err := wstore.DBGetSingleton[*waveobj.Client](ctx)","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wcore/wcore.go#L65-L101","documentation":"Returned when a new window cannot be created, typically a platform window-system or resource failure. The underlying error is wrapped with %w.","triggerScenarios":"CreateWindow fails during initial startup — e.g. the workspace id passed is invalid, or the wstore insert/update of the new window object fails.","commonSituations":"First launch where window creation hit a DB error; a stale/corrupt client.WindowIds entry; an invalid wsId after a failed starter workspace creation.","solutions":["Inspect the wrapped CreateWindow error for the root cause","Verify the workspace referenced by wsId exists in the DB","Delete/rename the Wave DB and relaunch for clean initialization","Check for concurrent Wave processes corrupting window state"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"ws, err := wstore.DBGet[*waveobj.Workspace](ctx, wsId)\n// ensure ws != nil before window creation proceeds","typeGuard":null,"tryCatchPattern":"_, err := wcore.CreateWindow(ctx, nil, wsId)\nif err != nil && strings.Contains(err.Error(), \"creating window\") {\n    log.Printf(\"window creation failed: %v\", err)\n}","preventionTips":["Pass a valid workspace OID (empty string for default on first launch)","Don't close windows concurrently during startup","Validate wsId exists in the DB before CreateWindow","Keep a clean DB state during upgrades"],"tags":["database","window","first-launch"],"backgroundTag":"window-creation-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}