{"record":{"id":"c940869e3586d40b","repo":"wavetermdev/waveterm","slug":"error-inserting-client-w","errorCode":null,"errorMessage":"error inserting client: %w","messagePattern":"error inserting client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/wcore/wcore.go","lineNumber":95,"sourceCode":"\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)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting client data: %w\", err)\n\t}\n\treturn clientData, nil\n}\n\nfunc SendWaveObjUpdate(oref waveobj.ORef) {\n\tctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)\n\tdefer cancelFn()\n\t// send a waveobj:update event\n\twaveObj, err := wstore.DBGetORef(ctx, oref)\n\tif err != nil {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wcore/wcore.go#L77-L113","documentation":"Returned when inserting a new client record into the client store fails, e.g. a database or ID conflict error. The underlying error is wrapped with %w.","triggerScenarios":"wstore.DBInsert(ctx, client) returns an error while inserting the new Client singleton — DB unavailable, schema conflict, or an existing client row colliding.","commonSituations":"Very first launch where the client record must be created; corrupted DB containing an unexpected client row; DB write failures from permissions or disk.","solutions":["Check the wrapped wstore error for the exact DB failure","Ensure the Wave data directory is writable","Remove a corrupted DB file to allow fresh client creation","Avoid running multiple Wave instances concurrently during first launch"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// no client singleton should exist yet\n_, err := wstore.DBGetSingleton[*waveobj.Client](ctx)\nif err == nil { log.Println(\"client already exists; skip CreateClient\") }","typeGuard":null,"tryCatchPattern":"client, err := wcore.CreateClient(ctx)\nif err != nil {\n    log.Printf(\"client creation failed: %v\", err)\n    return err\n}","preventionTips":["Run initialization only once per process","Verify data directory permissions before first launch","Avoid concurrent instances during first run","Check for disk-full conditions"],"tags":["database","client","persistence"],"backgroundTag":"database-insert-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}