{"record":{"id":"1fdb6832f4bd1b05","repo":"portainer/portainer","slug":"user-already-exists","errorCode":null,"errorMessage":"User already exists","messagePattern":"User already exists","errorType":"http","errorClass":"HandlerError","httpStatus":409,"severity":"error","filePath":"api/http/handler/users/handler.go","lineNumber":19,"sourceCode":"package users\n\nimport (\n\t\"errors\"\n\t\"net/http\"\n\n\tportainer \"github.com/portainer/portainer/api\"\n\t\"github.com/portainer/portainer/api/apikey\"\n\t\"github.com/portainer/portainer/api/dataservices\"\n\t\"github.com/portainer/portainer/api/http/security\"\n\t\"github.com/portainer/portainer/api/internal/authorization\"\n\t\"github.com/portainer/portainer/api/kubernetes/cli\"\n\thttperror \"github.com/portainer/portainer/pkg/libhttp/error\"\n\n\t\"github.com/gorilla/mux\"\n)\n\nvar (\n\terrUserAlreadyExists          = errors.New(\"User already exists\")\n\terrAdminAlreadyInitialized    = errors.New(\"An administrator user already exists\")\n\terrAdminCannotRemoveSelf      = errors.New(\"Cannot remove your own user account. Contact another administrator\")\n\terrCannotRemoveLastLocalAdmin = errors.New(\"Cannot remove the last local administrator account\")\n\terrCryptoHashFailure          = errors.New(\"Unable to hash data\")\n)\n\nfunc hideFields(user *portainer.User) {\n\tuser.Password = \"\"\n}\n\n// Handler is the HTTP handler used to handle user operations.\ntype Handler struct {\n\t*mux.Router\n\tbouncer                 security.BouncerService\n\tapiKeyService           apikey.APIKeyService\n\tDataStore               dataservices.DataStore\n\tCryptoService           portainer.CryptoService\n\tpasswordStrengthChecker security.PasswordStrengthChecker","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/portainer/portainer/blob/17e74456ff6e794b9d5439ec3fa06922aa18a3f8/api/http/handler/users/handler.go#L1-L37","documentation":"Error \"User already exists\" thrown in portainer/portainer.","triggerScenarios":"Thrown at api/http/handler/users/handler.go:19 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"17e74456ff6e794b9d5439ec3fa06922aa18a3f8","analyzedAt":"2026-08-26T23:09:01.915Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}