Internal server error when logging in via GitLab OAuth

My version of HedgeDoc is: 1.8.2, running through the docker image quay.io/hedgedoc/hedgedoc:1.8.2. I’m using postgres as database, version 11.6.

What I expected to happen:

The login is successful, and the user’s last files are shown.

What actually happened:

Internal server error is displayed, and the login is not successful (when loading the index page, the user is not logged in).

I already tried:

I found a similar post, but I don’t think that it is related (logs show different internal errors).

After reading that post, reviewed that the configuration matches the documentation.

The logs show a SequelizeUniqueConstraintError, but that is not much to go on (at least for me). The relevant error log from the server is:

codimd_1    | 2021-07-14T23:34:20.952Z error: 	auth callback failed: SequelizeUniqueConstraintError: Validation error
codimd_1    | SequelizeUniqueConstraintError: Validation error
codimd_1    |     at Query.formatError (/hedgedoc/node_modules/sequelize/lib/dialects/postgres/query.js:324:18)
codimd_1    |     at /hedgedoc/node_modules/sequelize/lib/dialects/postgres/query.js:113:24
codimd_1    |     at tryCatcher (/hedgedoc/node_modules/bluebird/js/release/util.js:16:23)
codimd_1    |     at Promise._settlePromiseFromHandler (/hedgedoc/node_modules/bluebird/js/release/promise.js:547:31)
codimd_1    |     at Promise._settlePromise (/hedgedoc/node_modules/bluebird/js/release/promise.js:604:18)
codimd_1    |     at Promise._settlePromise0 (/hedgedoc/node_modules/bluebird/js/release/promise.js:649:10)
codimd_1    |     at Promise._settlePromises (/hedgedoc/node_modules/bluebird/js/release/promise.js:729:18)
codimd_1    |     at _drainQueueStep (/hedgedoc/node_modules/bluebird/js/release/async.js:93:12)
codimd_1    |     at _drainQueue (/hedgedoc/node_modules/bluebird/js/release/async.js:86:9)
codimd_1    |     at Async._drainQueues (/hedgedoc/node_modules/bluebird/js/release/async.js:102:5)
codimd_1    |     at Immediate.Async.drainQueues [as _onImmediate] (/hedgedoc/node_modules/bluebird/js/release/async.js:15:14)
codimd_1    |     at processImmediate (node:internal/timers:464:21)

Hey @cgjgc,

sorry for coming around a bit late, but this sounds like something is up with the database. The error itself indicates that a unique constrain of the database is causing the problem. Could you check if there are any duplicate.

Do you have by any chance multiple user backends enabled? In theory when the profileids duplicate this could cause the error.

I initially used email, and then switched to Gitlab as user backend.

Accessing the Users table in the database, it seems that one of the users does not have a profileid. It also doesn’t have a profile, while the rest do. Should I set a unique profileid, or is there any other way to solve this?

With what user do you try to log in? The GitLab user or the email user?

I’m trying to log in via GitLab. The specific user is the one that doesn’t have a profile (nor profileid, as the rest have a different email from the one linked to that GitLab account.