{"record":{"id":"1728839b6f984212","repo":"wavetermdev/waveterm","slug":"error-getting-client-v","errorCode":null,"errorMessage":"error getting client: %v","messagePattern":"error getting client: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/server/main-server.go","lineNumber":430,"sourceCode":"\n\t// Remove WAVETERM env vars that leak from prod => dev\n\tos.Unsetenv(\"WAVETERM_CLIENTID\")\n\tos.Unsetenv(\"WAVETERM_WORKSPACEID\")\n\tos.Unsetenv(\"WAVETERM_TABID\")\n\tos.Unsetenv(\"WAVETERM_BLOCKID\")\n\tos.Unsetenv(\"WAVETERM_CONN\")\n\tos.Unsetenv(\"WAVETERM_JWT\")\n\tos.Unsetenv(\"WAVETERM_VERSION\")\n\n\treturn nil\n}\n\nfunc clearTempFiles() error {\n\tctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)\n\tdefer cancelFn()\n\tclient, err := wstore.DBGetSingleton[*waveobj.Client](ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting client: %v\", err)\n\t}\n\tfilestore.WFS.DeleteZone(ctx, client.TempOID)\n\treturn nil\n}\n\nfunc maybeStartPprofServer() {\n\tsettings := wconfig.GetWatcher().GetFullConfig().Settings\n\tif settings.DebugPprofMemProfileRate != nil {\n\t\truntime.MemProfileRate = *settings.DebugPprofMemProfileRate\n\t\tlog.Printf(\"set runtime.MemProfileRate to %d\\n\", runtime.MemProfileRate)\n\t}\n\tif settings.DebugPprofPort == nil {\n\t\treturn\n\t}\n\tpprofPort := *settings.DebugPprofPort\n\tif pprofPort < 1 || pprofPort > 65535 {\n\t\tlog.Printf(\"[error] debug:pprofport must be between 1 and 65535, got %d\\n\", pprofPort)\n\t\treturn","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/server/main-server.go#L412-L448","documentation":"clearTempFiles loads the singleton Client record from the wave store to find the temp file zone OID. If the DB read fails (corrupt DB, IO error, store not ready), the error is wrapped as \"error getting client: %v\" during server temp-file cleanup.","triggerScenarios":"Server startup/shutdown path calls clearTempFiles; wstore.DBGetSingleton[*waveobj.Client] returns an error (db open failure, IO error, corrupt record). Note it fails on error, not on a missing singleton.","commonSituations":"Disk I/O problems on the wave config DB; corrupted local store after a crash; running cleanup in tests without an initialized store.","solutions":["Inspect the wrapped inner error for the DB-level cause (permissions, corruption, lock).","Check/repair the wave config DB (wavebase data dir); restore from backup if corrupt.","Verify disk space and file permissions on the store location.","Make temp-file cleanup non-fatal (log and continue) so startup isn't blocked by cleanup issues.","Ensure the store is initialized before clearTempFiles runs."],"exampleFix":"// before\nfunc clearTempFiles() error {\n    client, err := wstore.DBGetSingleton[*waveobj.Client](ctx)\n    if err != nil {\n        return fmt.Errorf(\"error getting client: %v\", err)\n    }\n    ...\n}\n// after\nfunc clearTempFiles() error {\n    client, err := wstore.DBGetSingleton[*waveobj.Client](ctx)\n    if err != nil {\n        log.Printf(\"clearTempFiles: skipping, %v\", err) // non-fatal cleanup\n        return nil\n    }\n    ...\n}","handlingStrategy":"try-catch","validationCode":"// ensure the wave store is initialized/open before running cleanup\nif err := wstore.EnsureDB(ctx); err != nil { return err }","typeGuard":null,"tryCatchPattern":"if err := clearTempFiles(); err != nil {\n    log.Printf(\"temp file cleanup skipped: %v\", err) // non-fatal\n}","preventionTips":["Treat cleanup failures as non-fatal during startup/shutdown.","Monitor disk space and permissions on the wave data dir.","Back up/repair the config DB rather than ignoring corruption.","Initialize the store before any DB reads in cleanup paths."],"tags":["go","database","startup","cleanup"],"backgroundTag":"database-read-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}