{"record":{"id":"c7351bd2881c270e","repo":"theonedev/onedev","slug":"error-authenticating-user","errorCode":null,"errorMessage":"Error authenticating user","messagePattern":"Error authenticating user","errorType":"exception","errorClass":"AuthenticationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/security/DefaultAuthenticatingService.java","lineNumber":204,"sourceCode":"\t\t\t\t\t\t\t\t\tthrow new AuthenticationException(MessageFormat.format(_T(\"Email address \\\"{0}\\\" already used by another account\"), emailAddressValue));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn newUser(userName, authenticated, authenticator.getDefaultGroup());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn newUser(userName, authenticated, authenticator.getDefaultGroup());\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new UnknownAccountException(_T(\"Invalid credentials\"));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\tif (e instanceof AuthenticationException) {\n\t\t\t\t\tlogger.debug(\"Authentication not passed\", e);\n\t\t\t\t\tthrow ExceptionUtils.unchecked(e);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.error(\"Error authenticating user\", e);\n\t\t\t\t\tthrow new AuthenticationException(_T(\"Error authenticating user\"), e);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic Object writeReplace() throws ObjectStreamException {\n\t\treturn new ManagedSerializedForm(AuthenticatingService.class);\n\t}\n\n}\n","sourceCodeStart":186,"sourceCodeEnd":215,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/security/DefaultAuthenticatingService.java#L186-L215","documentation":"Catch-all wrapper in doGetAuthenticationInfo: any non-AuthenticationException exception escaping the authentication logic is logged and rethrown as AuthenticationException('Error authenticating user') with the original as cause. It signals an unexpected internal problem (database, plugin authenticator crash, etc.), not failed credentials.","triggerScenarios":"Any RuntimeException during login processing - e.g. the configured external authenticator throws a non-auth exception, DB connectivity issues while loading the user, NPE in email sync code.","commonSituations":"Misbehaving custom authenticator plugin; database unavailable or schema mismatch after upgrade; LDAP server errors surfacing as raw exceptions from the authenticator.","solutions":["Read the server log for the logged 'Error authenticating user' stack trace to find the root cause.","If caused by an external authenticator, verify the directory/SSO server is reachable and its config is valid.","Check database health/connectivity if the trace points to persistence calls.","Update or fix the custom authenticator plugin; report a bug with the stack trace if it is core code."],"exampleFix":"// before: authenticator.authenticate() throws NPE -> 'Error authenticating user'\n// after: fix authenticator config (e.g. correct LDAP bind DN/base DN) so authenticate() succeeds","handlingStrategy":"try-catch","validationCode":"// Pre-flight: verify DB reachable and external authenticator responds before login attempts\ncheckDatabaseAlive();\ncheckAuthenticatorEndpointReachable();","typeGuard":"function authInfrastructureHealthy(db, settings) { return db.alive && (settings.authenticator == null || settings.authenticator.reachable); }","tryCatchPattern":"try {\n  authenticate(user, pass);\n} catch (AuthenticationException e) {\n  if (e.getMessage().equals(\"Error authenticating user\") && e.getCause() != null) {\n    inspectRootCause(e.getCause()); // server log has full stack trace\n  }\n}","preventionTips":["Monitor DB and directory/SSO availability; most wrapped failures come from these.","Test custom authenticator plugins against the server version before deploying.","Always log the cause chain server-side when debugging auth failures."],"tags":["authentication","internal-error","unexpected-exception"],"backgroundTag":"authentication-failed","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}