{"record":{"id":"cf31facb623af149","repo":"plandex-ai/plandex","slug":"error-getting-user","errorCode":null,"errorMessage":"error getting user","messagePattern":"error getting user","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/auth_helpers.go","lineNumber":503,"sourceCode":"\tauthToken, err := db.ValidateAuthToken(parsed.Token)\n\n\tif err != nil {\n\t\tlog.Printf(\"error validating auth token: %v\\n\", err)\n\n\t\twriteApiError(w, shared.ApiError{\n\t\t\tType:   shared.ApiErrorTypeInvalidToken,\n\t\t\tStatus: http.StatusUnauthorized,\n\t\t\tMsg:    \"Invalid auth token\",\n\t\t})\n\t\treturn nil\n\t}\n\n\tuser, err := db.GetUser(authToken.UserId)\n\n\tif err != nil {\n\t\tlog.Printf(\"error getting user: %v\\n\", err)\n\t\tif raiseErr {\n\t\t\thttp.Error(w, \"error getting user\", http.StatusInternalServerError)\n\t\t}\n\t\treturn nil\n\t}\n\n\tif !requireOrg {\n\t\treturn &types.ServerAuth{\n\t\t\tAuthToken: authToken,\n\t\t\tUser:      user,\n\t\t}\n\t}\n\n\tif parsed.OrgId == \"\" {\n\t\tlog.Println(\"no org id\")\n\t\tif raiseErr {\n\t\t\thttp.Error(w, \"no org id\", http.StatusUnauthorized)\n\t\t}\n\t\treturn nil\n\t}","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/auth_helpers.go#L485-L521","documentation":"The auth token was valid but db.GetUser(authToken.UserId) failed, so execAuthenticate logs 'error getting user' and returns HTTP 500 when raiseErr is true. This is a database/backend failure fetching the user record, not an invalid token.","triggerScenarios":"ValidateAuthToken returned a token whose UserId no longer exists in the users table, the DB is down/unreachable, or the users query errors (timeout, constraint, replication lag).","commonSituations":"Deleted user accounts with still-cached tokens; database outages or connection-pool exhaustion; read-replica lag right after signup.","solutions":["Check database health/connectivity and retry the request","Invalidate the client's token and force re-login (user record likely deleted)","Check db.GetUser query/logs for the underlying SQL error","Verify token cleanup removes tokens for deleted users"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := doCall(ctx); err != nil {\n\tvar apiErr *APIError\n\tif errors.As(err, &apiErr) && apiErr.StatusCode == 500 && strings.Contains(apiErr.Message, \"error getting user\") {\n\t\t// likely deleted user or DB issue: force re-login or retry after DB recovery\n\t\tclearTokenAndReauthenticate()\n\t\treturn nil\n\t}\n\treturn err\n}","preventionTips":["Monitor database health and alert on user-table query failures","Cascade-delete auth tokens when users are removed","Retry transient DB failures with backoff","Keep read-replica lag in mind for freshly created accounts"],"tags":["database","auth","internal-server-error"],"backgroundTag":"database-query-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}