{"record":{"id":"a07ce411314855da","repo":"wavetermdev/waveterm","slug":"error-updating-client-w","errorCode":null,"errorMessage":"error updating client: %w","messagePattern":"error updating client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/wcore/wcore.go","lineNumber":50,"sourceCode":"func EnsureInitialData() (bool, error) {\n\t// does not need to run in a transaction since it is called on startup\n\tctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)\n\tdefer cancelFn()\n\tclient, err := wstore.DBGetSingleton[*waveobj.Client](ctx)\n\tfirstLaunch := false\n\tif err == wstore.ErrNotFound {\n\t\tclient, err = CreateClient(ctx)\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"error creating client: %w\", err)\n\t\t}\n\t\tfirstLaunch = true\n\t}\n\tif client.TempOID == \"\" {\n\t\tlog.Println(\"client.TempOID is empty\")\n\t\tclient.TempOID = uuid.NewString()\n\t\terr = wstore.DBUpdate(ctx, client)\n\t\tif err != nil {\n\t\t\treturn firstLaunch, fmt.Errorf(\"error updating client: %w\", err)\n\t\t}\n\t}\n\tif client.InstallId == \"\" {\n\t\tlog.Println(\"client.InstallId is empty\")\n\t\tclient.InstallId = uuid.NewString()\n\t\terr = wstore.DBUpdate(ctx, client)\n\t\tif err != nil {\n\t\t\treturn firstLaunch, fmt.Errorf(\"error updating client: %w\", err)\n\t\t}\n\t}\n\tlog.Printf(\"clientid: %s\\n\", client.OID)\n\twstore.SetClientId(client.OID)\n\tif len(client.WindowIds) == 1 {\n\t\tlog.Println(\"client has one window\")\n\t\tCheckAndFixWindow(ctx, client.WindowIds[0])\n\t\treturn firstLaunch, nil\n\t}\n\tif len(client.WindowIds) > 0 {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wcore/wcore.go#L32-L68","documentation":"EnsureInitialData generates a TempOID for a client record that lacks one and persists it via wstore.DBUpdate. This error wraps a failure of that DB update, so the client record could not be written back to the store during startup initialization.","triggerScenarios":"wstore.DBUpdate(ctx, client) returns an error while persisting the newly generated TempOID — e.g. the wavetool DB is corrupt/locked, the client singleton row is missing, or the DB write fails on disk I/O.","commonSituations":"First launch on a machine with a corrupted or read-only Wave data directory; concurrent Wave processes contending for the sqlite database; disk full or permission errors on ~/.waveterm.","solutions":["Check Wave data directory (~/.waveterm) permissions and free disk space","Delete/rename the possibly corrupted wavetool DB and relaunch to reinitialize","Check logs for the wrapped wstore error (e.g. 'database is locked') and address that cause","Ensure no other Wave instance is running and holding the DB lock"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"clientData, err := wcore.GetClientData(ctx)\nif err != nil { return err }\nif clientData.TempOID == \"\" { log.Println(\"TempOID will be generated; ensure DB is writable\") }","typeGuard":null,"tryCatchPattern":"firstLaunch, err := wcore.EnsureInitialData(ctx)\nif err != nil {\n    var wrapped *fmt.wrapError\n    if errors.As(err, &wrapped) { log.Printf(\"init failed: %v\", wrapped.Unwrap()) }\n    return err\n}","preventionTips":["Ensure ~/.waveterm is writable before launching","Close other Wave instances to avoid DB locks","Monitor disk space on the data directory volume","Check DB integrity after OS crashes"],"tags":["database","startup","persistence"],"backgroundTag":"database-update-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}