plane icon indicating copy to clipboard operation
plane copied to clipboard

[bug]: Cannot invite more than one user to self-hosted Plane

Open sturnclaw opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

Attempting to invite one user to a self-hosted plane instance succeeds with no issue. Attempting to invite a subsequent user (different email address) fails with duplicate key value violates unique constraint "user_username_key" as the created User object has no username value.

This appears to be caused by a missing username kwarg parameter when bulk-creating the User object in this function:

https://github.com/makeplane/plane/blob/1ed7935bf0cb56b244cc26d8a4063573da1e93bc/apiserver/plane/api/views/workspace.py#L280C23-L280C23

This is a critical blocker for attempting to use the self-hosted version of plane in the default configuration.

Attached is a copy of the relevant log from the error with the email and password fields redacted. Note the NULL value for the "username" key.

plane-db         | 2023-06-29 22:21:00.997 UTC [3656] ERROR:  duplicate key value violates unique constraint "user_username_key"
plane-db         | 2023-06-29 22:21:00.997 UTC [3656] DETAIL:  Key (username)=() already exists.
plane-db         | 2023-06-29 22:21:00.997 UTC [3656] STATEMENT:  INSERT INTO "users" ("password", "last_login", "id", "username", "mobile_number", "email", "first_name", "last_name", "avatar", "date_joined", "created_at", "updated_at", "last_location", "created_location", "is_superuser", "is_managed", "is_password_expired", "is_active", "is_staff", "is_email_verified", "is_password_autoset", "is_onboarded", "token", "billing_address_country", "billing_address", "has_billing_address", "user_timezone", "last_active", "last_login_time", "last_logout_time", "last_login_ip", "last_logout_ip", "last_login_medium", "last_login_uagent", "token_updated_at", "last_workspace_id", "my_issues_prop", "role", "is_bot", "theme") VALUES ('<autogen password>', NULL, '86797889-1b64-4ab8-a54d-61b868aaaa93'::uuid, '', NULL, '<email address>', '', '', '', '2023-06-29T22:21:00.995912+00:00'::timestamptz, '2023-06-29T22:21:00.995926+00:00'::timestamptz, '2023-06-29T22:21:00.995932+00:00'::timestamptz, '', '', false, false, false, true, false, false, true, false, '', 'INDIA', NULL, false, 'Asia/Kolkata', '2023-06-29T22:21:00.995544+00:00'::timestamptz, NULL, NULL, '', '', 'email', '', NULL, NULL, NULL, NULL, false, '{}')

Steps to reproduce

  1. Self-host Plane using the default docker-compose-hub.yml configuration with ENABLE_SIGNUP=0.
  2. Invite one user to the workspace.
  3. User joins successfully.
  4. Invite another user to the workspace.
  5. Error in plane-db logs and no invitation is sent or user account created.

Browser

Mozilla Firefox

Version

Self-hosted

sturnclaw avatar Jun 29 '23 22:06 sturnclaw

Hi @Web-eWorks, thanks for raising this issue. This is due to empty usernames being set while creating new users. PR #1441 should fix the issue.

pablohashescobar avatar Jun 30 '23 04:06 pablohashescobar