twenty icon indicating copy to clipboard operation
twenty copied to clipboard

Lost Access When Creating New User via API

Open inside-mo opened this issue 5 months ago • 2 comments

Bug Description

I honestly can't say what happened exactly or how. I was playing around trying to create new users via API in order to see, if I can log in with them (by using forgot password). Not sure how it happened, but suddenly I lost (almost) all access to 20. Whenever I try to log in with my user, I get the error message "User workspace not found". But when I get all users via API, my user is still there. Using "forgot password" gets me a reset link and everything, but I still can't log in once I set a new password, getting the same error over and over again.

BTW: Creating other / new users works via the API works and I can use the PW forgotten procedure with them. But it's the same story as with my user: They get an email and can actually set a password. But they cannot log in afterwords and get the same error message.

I then figured out that my users had the same "position" (still not sure what this variable is for). And as soon as I was the only user in the workspace, things worked again.

Get workspace members API request: [ { "data": { "workspaceMembers": [ { "position": 0, "name": { "firstName": "first name", "lastName": "last name" }, "colorScheme": "System", "locale": "en", "avatarUrl": "profile-picture/original/b43ffcd8-8897-4049-a79b-8b17bec9527f.png", "userEmail": "[email protected]", "userId": "a13727a7-ae91-44dd-a7eb-1b2e19fc7f60", "timeZone": "system", "dateFormat": "SYSTEM", "timeFormat": "SYSTEM", "searchVector": "'[email protected]':3 'first name':1 'last name':2", "id": "04cea7bb-ecf2-4347-bcff-0050ddd9025f", "createdAt": "2025-06-24T08:53:19.923Z", "updatedAt": "2025-06-25T08:25:21.832Z", "deletedAt": null }, { "position": 0, "name": { "firstName": "Test", "lastName": "User" }, "colorScheme": "System", "locale": "en", "avatarUrl": "", "userEmail": "[email protected]", "userId": "cf5325e7-a0cf-4294-be8a-928ee09c0a08", "timeZone": "system", "dateFormat": "SYSTEM", "timeFormat": "SYSTEM", "searchVector": "'[email protected]':3 'test':1 'user':2", "id": "f1274b9a-230b-43c5-8cb8-61e1af6eed1d", "createdAt": "2025-06-29T15:23:20.778Z", "updatedAt": "2025-06-29T15:23:20.778Z", "deletedAt": null } ] }, "pageInfo": { "hasNextPage": false, "startCursor": "eyJpZCI6IjA0Y2VhN2JiLWVjZjItNDM0Ny1iY2ZmLTAwNTBkZGQ5MDI1ZiJ9", "endCursor": "eyJpZCI6ImYxMjc0YjlhLTIzMGItNDNjNS04Y2I4LTYxZTFhZjZlZWQxZCJ9" }, "totalCount": 2 } ]

Expected behavior

I feel that we should be able to create users via API with (accidentally) causing this kind of disruption for existing users.

Technical inputs

Here's my server log when I tried logging in with my primary user:

2025-06-29T15:37:40.739474049Z Exception Captured 2025-06-29T15:37:40.740061980Z { 2025-06-29T15:37:40.740072741Z operation: { name: 'GetCurrentUser', type: 'query' }, 2025-06-29T15:37:40.740077440Z document: 'query GetCurrentUser {\n' + 2025-06-29T15:37:40.740081208Z ' currentUser {\n' + 2025-06-29T15:37:40.740095075Z ' ...UserQueryFragment\n' + 2025-06-29T15:37:40.740097500Z ' __typename\n' + 2025-06-29T15:37:40.740099704Z ' }\n' + 2025-06-29T15:37:40.740101837Z '}\n' + 2025-06-29T15:37:40.740104032Z '\n' + 2025-06-29T15:37:40.740106156Z 'fragment UserQueryFragment on User {\n' + 2025-06-29T15:37:40.740108481Z ' id\n' + 2025-06-29T15:37:40.740111136Z ' firstName\n' + 2025-06-29T15:37:40.740113370Z ' lastName\n' + 2025-06-29T15:37:40.740115504Z ' email\n' + 2025-06-29T15:37:40.740117608Z ' canAccessFullAdminPanel\n' + 2025-06-29T15:37:40.740119763Z ' canImpersonate\n' + 2025-06-29T15:37:40.740121906Z ' supportUserHash\n' + 2025-06-29T15:37:40.740123981Z ' onboardingStatus\n' + 2025-06-29T15:37:40.740126105Z ' workspaceMember {\n' + 2025-06-29T15:37:40.740128229Z ' ...WorkspaceMemberQueryFragment\n' + 2025-06-29T15:37:40.740130343Z ' __typename\n' + 2025-06-29T15:37:40.740132427Z ' }\n' + 2025-06-29T15:37:40.740134651Z ' workspaceMembers {\n' + 2025-06-29T15:37:40.740136976Z ' ...WorkspaceMemberQueryFragment\n' + 2025-06-29T15:37:40.740139081Z ' __typename\n' + 2025-06-29T15:37:40.740141175Z ' }\n' + 2025-06-29T15:37:40.740143278Z ' deletedWorkspaceMembers {\n' + 2025-06-29T15:37:40.740145402Z ' ...DeletedWorkspaceMemberQueryFragment\n' + 2025-06-29T15:37:40.740147537Z ' __typename\n' + 2025-06-29T15:37:40.740149610Z ' }\n' + 2025-06-29T15:37:40.740151714Z ' currentUserWorkspace {\n' + 2025-06-29T15:37:40.740153819Z ' settingsPermissions\n' + 2025-06-29T15:37:40.740155903Z ' objectRecordsPermissions\n' + 2025-06-29T15:37:40.740157997Z ' objectPermissions {\n' + 2025-06-29T15:37:40.740160582Z ' ...ObjectPermissionFragment\n' + 2025-06-29T15:37:40.740162686Z ' __typename\n' + 2025-06-29T15:37:40.740164850Z ' }\n' + 2025-06-29T15:37:40.740166923Z ' __typename\n' + 2025-06-29T15:37:40.740169039Z ' }\n' + 2025-06-29T15:37:40.740171123Z ' currentWorkspace {\n' + 2025-06-29T15:37:40.740173206Z ' id\n' + 2025-06-29T15:37:40.740175281Z ' displayName\n' + 2025-06-29T15:37:40.740177384Z ' logo\n' + 2025-06-29T15:37:40.740179468Z ' inviteHash\n' + 2025-06-29T15:37:40.740185110Z ' allowImpersonation\n' + 2025-06-29T15:37:40.740187284Z ' activationStatus\n' + 2025-06-29T15:37:40.740189408Z ' isPublicInviteLinkEnabled\n' + 2025-06-29T15:37:40.740191532Z ' isGoogleAuthEnabled\n' + 2025-06-29T15:37:40.740193676Z ' isMicrosoftAuthEnabled\n' + 2025-06-29T15:37:40.740195790Z ' isPasswordAuthEnabled\n' + 2025-06-29T15:37:40.740199117Z ' subdomain\n' + 2025-06-29T15:37:40.740202404Z ' hasValidEnterpriseKey\n' + 2025-06-29T15:37:40.740205579Z ' customDomain\n' + 2025-06-29T15:37:40.740209016Z ' isCustomDomainEnabled\n' + 2025-06-29T15:37:40.740213886Z ' workspaceUrls {\n' + 2025-06-29T15:37:40.740221390Z ' ...WorkspaceUrlsFragment\n' + 2025-06-29T15:37:40.740225939Z ' __typename\n' + 2025-06-29T15:37:40.740229726Z ' }\n' + 2025-06-29T15:37:40.740233514Z ' featureFlags {\n' + 2025-06-29T15:37:40.740236890Z ' key\n' + 2025-06-29T15:37:40.740240647Z ' value\n' + 2025-06-29T15:37:40.740243864Z ' __typename\n' + 2025-06-29T15:37:40.740245908Z ' }\n' + 2025-06-29T15:37:40.740247942Z ' metadataVersion\n' + 2025-06-29T15:37:40.740250005Z ' currentBillingSubscription {\n' + 2025-06-29T15:37:40.740252100Z ' id\n' + 2025-06-29T15:37:40.740254504Z ' status\n' + 2025-06-29T15:37:40.740257641Z ' interval\n' + 2025-06-29T15:37:40.740260076Z ' metadata\n' + 2025-06-29T15:37:40.740262169Z ' billingSubscriptionItems {\n' + 2025-06-29T15:37:40.740264293Z ' id\n' + 2025-06-29T15:37:40.740266347Z ' hasReachedCurrentPeriodCap\n' + 2025-06-29T15:37:40.740268481Z ' quantity\n' + 2025-06-29T15:37:40.740270566Z ' billingProduct {\n' + 2025-06-29T15:37:40.740272800Z ' name\n' + 2025-06-29T15:37:40.740275044Z ' description\n' + 2025-06-29T15:37:40.740277138Z ' metadata {\n' + 2025-06-29T15:37:40.740279313Z ' planKey\n' + 2025-06-29T15:37:40.740281397Z ' priceUsageBased\n' + 2025-06-29T15:37:40.740283490Z ' productKey\n' + 2025-06-29T15:37:40.740285595Z ' __typename\n' + 2025-06-29T15:37:40.740287690Z ' }\n' + 2025-06-29T15:37:40.740289803Z ' __typename\n' + 2025-06-29T15:37:40.740291897Z ' }\n' + 2025-06-29T15:37:40.740298439Z [ 2025-06-29T15:37:40.740300725Z ' __typename\n' + 2025-06-29T15:37:40.740302919Z ' }\n' + 2025-06-29T15:37:40.740309320Z Error: User workspace not found 2025-06-29T15:37:40.740312647Z at /app/packages/twenty-server/dist/src/engine/core-modules/user/user.resolver.js:183:23 2025-06-29T15:37:40.740315193Z at Array.map () 2025-06-29T15:37:40.740318229Z at UserResolver.workspaceMembers (/app/packages/twenty-server/dist/src/engine/core-modules/user/user.resolver.js:180:66) 2025-06-29T15:37:40.740320643Z at process.processTicksAndRejections (node:internal/process/task_queues:105:5) 2025-06-29T15:37:40.740322927Z at async Object.target [as workspaceMembers] (/app/node_modules/@nestjs/core/helpers/external-context-creator.js:74:28) 2025-06-29T15:37:40.740325172Z at async field.resolve (/app/node_modules/@envelop/on-resolve/cjs/index.js:36:42) 2025-06-29T15:37:40.740327336Z at async /app/node_modules/@graphql-tools/executor/cjs/execution/promiseForObject.js:18:35 2025-06-29T15:37:40.740329661Z at async Promise.all (index 9) { 2025-06-29T15:37:40.740331895Z extensions: {} 2025-06-29T15:37:40.740334009Z } 2025-06-29T15:37:40.740336143Z ] 2025-06-29T15:37:40.740342315Z ' __typename\n' + 2025-06-29T15:37:40.740344710Z ' }\n' + 2025-06-29T15:37:40.740346925Z ' billingSubscriptions {\n' + 2025-06-29T15:37:40.740349098Z ' id\n' + 2025-06-29T15:37:40.740351213Z ' status\n' + 2025-06-29T15:37:40.740353306Z ' metadata\n' + 2025-06-29T15:37:40.740355390Z ' __typename\n' + 2025-06-29T15:37:40.740357604Z ' }\n' + 2025-06-29T15:37:40.740359679Z ' workspaceMembersCount\n' + 2025-06-29T15:37:40.740362013Z ' defaultRole {\n' + 2025-06-29T15:37:40.740364097Z ' ...RoleFragment\n' + 2025-06-29T15:37:40.740366462Z ' __typename\n' + 2025-06-29T15:37:40.740368666Z ' }\n' + 2025-06-29T15:37:40.740371000Z ' __typename\n' + 2025-06-29T15:37:40.740373135Z ' }\n' + 2025-06-29T15:37:40.740375229Z ' availableWorkspaces {\n' + 2025-06-29T15:37:40.740377323Z ' ...AvailableWorkspacesFragment\n' + 2025-06-29T15:37:40.740379477Z ' __typename\n' + 2025-06-29T15:37:40.740381571Z ' }\n' + 2025-06-29T15:37:40.740383705Z ' userVars\n' + 2025-06-29T15:37:40.740385859Z ' __typename\n' + 2025-06-29T15:37:40.740388063Z '}\n' + 2025-06-29T15:37:40.740390228Z '\n' + 2025-06-29T15:37:40.740402541Z 'fragment WorkspaceMemberQueryFragment on WorkspaceMember {\n' + 2025-06-29T15:37:40.740404977Z ' id\n' + 2025-06-29T15:37:40.740407162Z ' name {\n' + 2025-06-29T15:37:40.740409275Z ' firstName\n' + 2025-06-29T15:37:40.740411469Z ' lastName\n' + 2025-06-29T15:37:40.740413563Z ' __typename\n' + 2025-06-29T15:37:40.740415717Z ' }\n' + 2025-06-29T15:37:40.740417791Z ' colorScheme\n' + 2025-06-29T15:37:40.740419866Z ' avatarUrl\n' + 2025-06-29T15:37:40.740422070Z ' locale\n' + 2025-06-29T15:37:40.740424164Z ' userEmail\n' + 2025-06-29T15:37:40.740445235Z ' timeZone\n' + 2025-06-29T15:37:40.740453612Z ' dateFormat\n' + 2025-06-29T15:37:40.740455875Z ' timeFormat\n' + 2025-06-29T15:37:40.740457980Z ' __typename\n' + 2025-06-29T15:37:40.740460123Z '}\n' + 2025-06-29T15:37:40.740462238Z '\n' + 2025-06-29T15:37:40.740464322Z 'fragment DeletedWorkspaceMemberQueryFragment on DeletedWorkspaceMember {\n' + 2025-06-29T15:37:40.740466567Z ' id\n' + 2025-06-29T15:37:40.740468651Z ' name {\n' + 2025-06-29T15:37:40.740470815Z ' firstName\n' + 2025-06-29T15:37:40.740472918Z ' lastName\n' + 2025-06-29T15:37:40.740474992Z ' __typename\n' + 2025-06-29T15:37:40.740477187Z ' }\n' + 2025-06-29T15:37:40.740479342Z ' avatarUrl\n' + 2025-06-29T15:37:40.740481426Z ' userEmail\n' + 2025-06-29T15:37:40.740483510Z ' __typename\n' + 2025-06-29T15:37:40.740485603Z '}\n' + 2025-06-29T15:37:40.740487907Z '\n' + 2025-06-29T15:37:40.740490142Z 'fragment ObjectPermissionFragment on ObjectPermission {\n' + 2025-06-29T15:37:40.740492276Z ' objectMetadataId\n' + 2025-06-29T15:37:40.740494992Z ' canReadObjectRecords\n' + 2025-06-29T15:37:40.740497156Z ' canUpdateObjectRecords\n' + 2025-06-29T15:37:40.740499270Z ' canSoftDeleteObjectRecords\n' + 2025-06-29T15:37:40.740501384Z ' canDestroyObjectRecords\n' + 2025-06-29T15:37:40.740524670Z ' __typename\n' + 2025-06-29T15:37:40.740527886Z '}\n' + 2025-06-29T15:37:40.740530050Z '\n' + 2025-06-29T15:37:40.740532134Z 'fragment WorkspaceUrlsFragment on WorkspaceUrls {\n' + 2025-06-29T15:37:40.740534258Z ' subdomainUrl\n' + 2025-06-29T15:37:40.740536333Z ' customUrl\n' + 2025-06-29T15:37:40.740538417Z ' __typename\n' + 2025-06-29T15:37:40.740545920Z '}\n' + 2025-06-29T15:37:40.740548085Z '\n' + 2025-06-29T15:37:40.740550188Z 'fragment RoleFragment on Role {\n' + 2025-06-29T15:37:40.740552343Z ' id\n' + 2025-06-29T15:37:40.740554397Z ' label\n' + 2025-06-29T15:37:40.740556471Z ' description\n' + 2025-06-29T15:37:40.740558545Z ' icon\n' + 2025-06-29T15:37:40.740560629Z ' canUpdateAllSettings\n' + 2025-06-29T15:37:40.740562703Z ' isEditable\n' + 2025-06-29T15:37:40.740564877Z ' canReadAllObjectRecords\n' + 2025-06-29T15:37:40.740567022Z ' canUpdateAllObjectRecords\n' + 2025-06-29T15:37:40.740569156Z ' canSoftDeleteAllObjectRecords\n' + 2025-06-29T15:37:40.740571360Z ' canDestroyAllObjectRecords\n' + 2025-06-29T15:37:40.740573544Z ' __typename\n' + 2025-06-29T15:37:40.740575618Z '}\n' + 2025-06-29T15:37:40.740577682Z '\n' + 2025-06-29T15:37:40.740579776Z 'fragment AvailableWorkspacesFragment on AvailableWorkspaces {\n' + 2025-06-29T15:37:40.740582161Z ' availableWorkspacesForSignIn {\n' + 2025-06-29T15:37:40.740584516Z ' ...AvailableWorkspaceFragment\n' + 2025-06-29T15:37:40.740586640Z ' __typename\n' + 2025-06-29T15:37:40.740588724Z ' }\n' + 2025-06-29T15:37:40.740590777Z ' availableWorkspacesForSignUp {\n' + 2025-06-29T15:37:40.740592871Z ' ...AvailableWorkspaceFragment\n' + 2025-06-29T15:37:40.740594975Z ' __typename\n' + 2025-06-29T15:37:40.740597131Z ' }\n' + 2025-06-29T15:37:40.740599164Z ' __typename\n' + 2025-06-29T15:37:40.740601488Z '}\n' + 2025-06-29T15:37:40.740603553Z '\n' + 2025-06-29T15:37:40.740605627Z 'fragment AvailableWorkspaceFragment on AvailableWorkspace {\n' + 2025-06-29T15:37:40.740607770Z ' id\n' + 2025-06-29T15:37:40.740609854Z ' displayName\n' + 2025-06-29T15:37:40.740611969Z ' loginToken\n' + 2025-06-29T15:37:40.740629273Z ' inviteHash\n' + 2025-06-29T15:37:40.740631457Z ' personalInviteToken\n' + 2025-06-29T15:37:40.740633681Z ' workspaceUrls {\n' + 2025-06-29T15:37:40.740635865Z ' subdomainUrl\n' + 2025-06-29T15:37:40.740637969Z ' customUrl\n' + 2025-06-29T15:37:40.740640034Z ' __typename\n' + 2025-06-29T15:37:40.740642108Z ' }\n' + 2025-06-29T15:37:40.740644161Z ' logo\n' + 2025-06-29T15:37:40.740646205Z ' sso {\n' + 2025-06-29T15:37:40.740652177Z ' type\n' + 2025-06-29T15:37:40.740654512Z ' id\n' + 2025-06-29T15:37:40.740656566Z ' issuer\n' + 2025-06-29T15:37:40.740658620Z ' name\n' + 2025-06-29T15:37:40.740660704Z ' status\n' + 2025-06-29T15:37:40.740662778Z ' __typename\n' + 2025-06-29T15:37:40.740664841Z ' }\n' + 2025-06-29T15:37:40.740666885Z ' __typename\n' + 2025-06-29T15:37:40.740668959Z '}', 2025-06-29T15:37:40.740671344Z user: User { 2025-06-29T15:37:40.740673428Z id: 'a13727a7-ae91-44dd-a7eb-1b2e19fc7f60', 2025-06-29T15:37:40.740675523Z firstName: '', 2025-06-29T15:37:40.740677586Z lastName: '', 2025-06-29T15:37:40.740679650Z email: '[email protected]', 2025-06-29T15:37:40.740681744Z defaultAvatarUrl: null, 2025-06-29T15:37:40.740683848Z isEmailVerified: false, 2025-06-29T15:37:40.740685963Z disabled: false, 2025-06-29T15:37:40.740688548Z passwordHash: 'abcdefgh', 2025-06-29T15:37:40.740690852Z canImpersonate: true, 2025-06-29T15:37:40.740693567Z canAccessFullAdminPanel: true, 2025-06-29T15:37:40.740695741Z createdAt: 2025-06-24T08:52:56.954Z, 2025-06-29T15:37:40.740697905Z updatedAt: 2025-06-29T15:14:00.624Z, 2025-06-29T15:37:40.740700000Z deletedAt: null, 2025-06-29T15:37:40.740702074Z locale: 'de-DE' 2025-06-29T15:37:40.740704198Z }, 2025-06-29T15:37:40.740706473Z workspace: { 2025-06-29T15:37:40.740709037Z id: 'd4da2e94-6485-451d-a8f5-cbd3f93569a3', 2025-06-29T15:37:40.740711121Z displayName: 'MyWorkspace', 2025-06-29T15:37:40.740713205Z createdAt: '2025-06-24T08:52:56.937Z', 2025-06-29T15:37:40.740715330Z activationStatus: 'ACTIVE' 2025-06-29T15:37:40.740717414Z } 2025-06-29T15:37:40.740719468Z }

inside-mo avatar Jun 29 '25 15:06 inside-mo

Tried creating a new user and gave a position "2" and suddenly it happened all over again. So while this value wasn't the cause, creating new users via API somehow disrupts my existing admin user.

inside-mo avatar Jun 29 '25 15:06 inside-mo

I asked other employees to create users and that luckily worked out fine. I also retried creating a user via Tor and that also worked. I get the impression the error is somehow related to me being logged in to Twenty when creating a user with the API.

inside-mo avatar Jun 30 '25 21:06 inside-mo

Closing it as it's hard to replicate. Keeping an eye on Sentry in case it comes back! 👀 Thanks for the issues @inside-mo

Bonapara avatar Jul 21 '25 12:07 Bonapara

Replicated the issue with 1.6.7 (self hosted)

Step 1 : In REST API playground, created a workspaceMember with custom First Name and Last Name.

Step 2 : Logout or open incognito browser

Step 3 : Try to login. It fails.

Step 4 : Delete the workspaceMember with restAPI

Step 5 : Log in.

Technical inputs

Same behavior / logs as @inside-mo

In database, the New User line is added in table "workspace-abcde..."."workspaceMember", with an ID and a userID. However, it doesn't appear in the "core"."user" table.

BersteinMilza avatar Sep 25 '25 14:09 BersteinMilza