Not able to log in. No metadata for User was found.

Hello, I have a strange problem with a new installation on Ubuntu v22.04. I have a new instance of the latest Twenty server v0.23.0 (a new build was made, running without problems against a standalone PostgreSQL database). Also, a client-side code was built and run in a Chrome browser. But in a moment when I want to log in using the pre-filled login nametim@apple.dev, the server responses by the error message "code": "INTERNAL_SERVER_ERROR", "response": "No metadata for \"User\" was found.". It looks like there is no other recognizable problem. Even if I check the pre-feed database content, everything looks fine. The only thing I am aware of is that the PostgreSQL database is v14.11. Plus, there are no installed database extensions wrappers and mysql_fdw, but the latest pg_graphql has been installed. Is it possible that it can have any relation to the observed problem? The following commands were also executed, and except messages related to the missing extensions wrappers and mysql_fdw, no other errors.
yarn run database:init:prod
yarn run command:prod workspace:seed:dev
yarn run command:prod workspace:sync-metadata -f
yarn run database:init:prod
yarn run command:prod workspace:seed:dev
yarn run command:prod workspace:sync-metadata -f
It is worth to mention that seeding the sample database data has no effect to the described error. It is the same in both cases. Or any other tip on where to find the source of the problem? I wanted to keep the problem description simple, but if necessary, I can add more details, including code. Thanks a lot for any help.
40 Replies
Miloš Lapiš
Miloš Lapiš4w ago
Payload of the POST request /graphql:
{
"operationName": "CheckUserExists",
"variables": {
"email": "tim@apple.dev"
},
"query": "query CheckUserExists($email: String!, $captchaToken: String) {
checkUserExists(email: $email, captchaToken: $captchaToken) {
exists
__typename
}
}"
}
{
"operationName": "CheckUserExists",
"variables": {
"email": "tim@apple.dev"
},
"query": "query CheckUserExists($email: String!, $captchaToken: String) {
checkUserExists(email: $email, captchaToken: $captchaToken) {
exists
__typename
}
}"
}
Miloš Lapiš
Miloš Lapiš4w ago
No description
Miloš Lapiš
Miloš Lapiš4w ago
If I compare our case with the exactly the same operation on https://demo.twenty.com, it is evident that in our case captchaToken variable is not sent as a part of the request. It is a question what is different in our case. Any idea?
{
"operationName": "CheckUserExists",
"variables": {
"email": "noah@demo.dev",
"captchaToken": "03AFcWeA7CI2H...JYTCBbP8AO8s-4VPFjrQFcXFSU"
},
"query": "query CheckUserExists($email: String!, $captchaToken: String) {
checkUserExists(email: $email, captchaToken: $captchaToken) {
exists
__typename
}
}"
}
{
"operationName": "CheckUserExists",
"variables": {
"email": "noah@demo.dev",
"captchaToken": "03AFcWeA7CI2H...JYTCBbP8AO8s-4VPFjrQFcXFSU"
},
"query": "query CheckUserExists($email: String!, $captchaToken: String) {
checkUserExists(email: $email, captchaToken: $captchaToken) {
exists
__typename
}
}"
}
Can our problem be related to the fact that the client config for the captcha is not defined? There is no information in the documentation what is necessary to do for the self-hosting case, except simply listing environment variables CAPTCHA_DRIVER, CAPTCHA_SITE_KEY, CAPTCHA_SECRET_KEY on the page https://twenty.com/developers/section/self-hosting/self-hosting-var. Is it possible to disable the captcha for self-hosting cases, especially when they are just demonstration installations? Doesn't it mean the value "provider": null represents a disabled state?
{
"data": {
"clientConfig": {
.....,
"captcha": {
"__typename": "Captcha",
"provider": null,
"siteKey": null
},
...
}
{
"data": {
"clientConfig": {
.....,
"captcha": {
"__typename": "Captcha",
"provider": null,
"siteKey": null
},
...
}
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
Why would you use captcha if there's no need to use it when self-hosting unless it's self-hosted for company?
Miloš Lapiš
Miloš Lapiš4w ago
@ɃØĦɆᵾS I am trying to find any, even theoretical, possible reason as I am fighting with the No metadata for User was found. error. Actually, I have confirmed that the reCaptcha has no effect on our problem. Even with the same request as on https://demo.twenty.com, I am still receiving the same error when trying to log in.
{
"operationName": "CheckUserExists",
"variables": {
"email": "tim@apple.dev",
"captchaToken": "03AFcWeA6ahftIph....70SKrvj1-Kz3BwuzFgMiO"
},
"query": "query CheckUserExists($email: String!, $captchaToken: String) {
checkUserExists(email: $email, captchaToken: $captchaToken) {
exists
__typename
}
}"
}
{
"operationName": "CheckUserExists",
"variables": {
"email": "tim@apple.dev",
"captchaToken": "03AFcWeA6ahftIph....70SKrvj1-Kz3BwuzFgMiO"
},
"query": "query CheckUserExists($email: String!, $captchaToken: String) {
checkUserExists(email: $email, captchaToken: $captchaToken) {
exists
__typename
}
}"
}
Miloš Lapiš
Miloš Lapiš4w ago
@ɃØĦɆᵾS This the site URL, if you want to look: https://app-44d-3000.prg1.zerops.app
Twenty
A modern open-source CRM
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
Okay, so now few questions: 1. How did you exactly host app? Using 1-click deploy or local setup, if local setup, then DB is in Docker or directly on Linux? 2. Does .env in packages/twenty-server has captcha variables uncommented? (they're described as optional)
Miloš Lapiš
Miloš Lapiš4w ago
1. How did you exactly host app? Using 1-click deploy or local setup, if local setup, then DB is in Docker or directly on Linux?
I have used the original Docker script to create my own local script to do all necessary steps on a Linux Ubuntu machine (container). So no Docker things are used in the end. The PostgreSQL database is running on a standalone Ubuntu container. @ɃØĦɆᵾS If it can help you, these are the steps how the Twenty server has been built:
git clone https://github.com/twentyhq/twenty.git
mkdir api
cd twenty
cp ./package.json ./yarn.lock ./.yarnrc.yml ./tsconfig.base.json ./nx.json ../api/
cp -r --parents ./.yarn/releases ../api/
cp --parents ./packages/twenty-emails/package.json ../api/
cp --parents ./packages/twenty-server/package.json ../api/
cp -r --parents ./packages/twenty-server/patches ../api/
cd ..
cd api
yarn && yarn cache clean && npx nx reset
cd ..
cd twenty
cp -r ./packages/twenty-emails/. ../api/packages/twenty-emails
cp -r ./packages/twenty-server/. ../api/packages/twenty-server
cd ..
cd api
npx nx run twenty-server:build
mv ./packages/twenty-server/dist ./packages/twenty-server/build
npx nx run twenty-server:build:packageJson
mv ./packages/twenty-server/dist/package.json ./packages/twenty-server/package.json
rm -rf ./packages/twenty-server/dist
mv ./packages/twenty-server/build ./packages/twenty-server/dist
cd ..
cd api/packages/twenty-server
yarn run database:init:prod
yarn run command:prod workspace:seed:dev
yarn run command:prod workspace:sync-metadata -f
git clone https://github.com/twentyhq/twenty.git
mkdir api
cd twenty
cp ./package.json ./yarn.lock ./.yarnrc.yml ./tsconfig.base.json ./nx.json ../api/
cp -r --parents ./.yarn/releases ../api/
cp --parents ./packages/twenty-emails/package.json ../api/
cp --parents ./packages/twenty-server/package.json ../api/
cp -r --parents ./packages/twenty-server/patches ../api/
cd ..
cd api
yarn && yarn cache clean && npx nx reset
cd ..
cd twenty
cp -r ./packages/twenty-emails/. ../api/packages/twenty-emails
cp -r ./packages/twenty-server/. ../api/packages/twenty-server
cd ..
cd api
npx nx run twenty-server:build
mv ./packages/twenty-server/dist ./packages/twenty-server/build
npx nx run twenty-server:build:packageJson
mv ./packages/twenty-server/dist/package.json ./packages/twenty-server/package.json
rm -rf ./packages/twenty-server/dist
mv ./packages/twenty-server/build ./packages/twenty-server/dist
cd ..
cd api/packages/twenty-server
yarn run database:init:prod
yarn run command:prod workspace:seed:dev
yarn run command:prod workspace:sync-metadata -f
and run:
node api/packages/twenty-server/dist/src/main
node api/packages/twenty-server/dist/src/main
As the deployed code is taken:
./api/package.json
./api/node_modules/
./api/packages/twenty-server/package.json
./api/packages/twenty-server/node_modules/
./api/packages/twenty-server/dist/
./api/packages/twenty-emails/package.json
./api/packages/twenty-emails/dist/
./api/package.json
./api/node_modules/
./api/packages/twenty-server/package.json
./api/packages/twenty-server/node_modules/
./api/packages/twenty-server/dist/
./api/packages/twenty-emails/package.json
./api/packages/twenty-emails/dist/
@ɃØĦɆᵾS And these are the environment variables used to build and run:
ACCESS_TOKEN_SECRET
LOGIN_TOKEN_SECRET
REFRESH_TOKEN_SECRET
FILE_TOKEN_SECRET
PG_DATABASE_URL
SERVER_URL
FRONT_BASE_URL
SIGN_IN_PREFILLED
ACCESS_TOKEN_SECRET
LOGIN_TOKEN_SECRET
REFRESH_TOKEN_SECRET
FILE_TOKEN_SECRET
PG_DATABASE_URL
SERVER_URL
FRONT_BASE_URL
SIGN_IN_PREFILLED
2. Does .env in packages/twenty-server has captcha variables uncommented? (they're described as optional)
I am using directly defined environment variables, not through the .env file. Initially captcha envs were not used at all. Then I tried them, but the result was the same, so I can remove them again.
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
Frankly speaking, I have no clue what might went wrong except for seeding workspace with data as I'm not sure if it works properly (I guess it should overwrite existing data but it doesn't?), if you don't have any important data, you can try running npx nx database:reset twenty-server as this creates all proper schemas and inserts needed data
Miloš Lapiš
Miloš Lapiš4w ago
As I mentioned before, it looks that there should no be a problem, but it is. I guess that it is something really trivial, as normal. @ɃØĦɆᵾS Can help you if I pass and access database details to you? Are you able to look at the database if it looks normal? @ɃØĦɆᵾS What does the command npx nx database:reset mean in fact? As I am looking at the code, it represents the following steps. Because I am installing a fresh instance of the database (don't need ./scripts/truncate-db.ts), and there are no historical data. Then ./scripts/setup-db.ts is the same as "database:init:prod": "npx ts-node ./scripts/setup-db.ts && yarn database:migrate:prod". There is nothing to migrate.
"database:reset": {
"executor": "nx:run-commands",
"dependsOn": ["build"],
"options": {
"cwd": "packages/twenty-server",
"commands": [
"nx ts-node-no-deps -- ./scripts/truncate-db.ts",
"nx ts-node-no-deps -- ./scripts/setup-db.ts",
"nx database:migrate",
"nx command-no-deps -- workspace:seed:dev"
],
"parallel": false
}
}
"database:reset": {
"executor": "nx:run-commands",
"dependsOn": ["build"],
"options": {
"cwd": "packages/twenty-server",
"commands": [
"nx ts-node-no-deps -- ./scripts/truncate-db.ts",
"nx ts-node-no-deps -- ./scripts/setup-db.ts",
"nx database:migrate",
"nx command-no-deps -- workspace:seed:dev"
],
"parallel": false
}
}
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
From what I've checked: - truncate fetches all schemas and drops them - setup-db creates all schemas and extensions - database:migrate does some black magic in dist/ but by looking at other files it seems like it creates all necessary data - workspace:seed:dev is not in project.json (it's located in src/database/commands/data-seed-demo-workspace/services) but I'd guess it's responsible for inserting all data from src/database/typeorm-seeds As much as I'm willing to help you solve your problem, I don't feel like I'd be able to help you more than I can do here, also, I'm not a developer by any means 😄 If I were you, I'd wait for tomorrow when someone from core team will take care of it, I'm sorry I couldn't help you more
Miloš Lapiš
Miloš Lapiš4w ago
Thanks a lot for your effort anyway. Because I started with a new database instance, the truncating doesn't add anything new, and setup-db is called and finished, as expected. So the source of the problem should come from else. And, your recommendation sounds reasonable. 😻
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
I guess they did it so it can run on both new and existing setups in case something goes horribly wrong (like I'm doing way too often) After all, there's no big difference in time if database is truncated or not One thing, just to be sure, do you have records in core."user"?
Miloš Lapiš
Miloš Lapiš4w ago
@ɃØĦɆᵾS Yes, I have checked that.
No description
Want results from more Discord servers?
Add your server