goauthentik/authentik

Database error when upgrading to 2023.10 from a version older than 2023.8

Closed this issue ยท 15 comments

Describe your question/
Just updated to 2023.10.1 and since I'm already logged into authentik on a browser, everything is working, but since I tried another browser, I seem to be not getting the login screen, but getting either an iframe or html information as shown below. Not sure what else is needed, but will provide if asked.

Relevant infos

<title> authentik </title> <script type="36da15029b380e93da54aebd-text/javascript"> window.authentik = { locale: "en-us", config: JSON.parse(''), tenant: JSON.parse(''), versionFamily: "", versionSubdomain: "", build: "", }; window.addEventListener("DOMContentLoaded", () => { }); </script> <script src="/static/dist/poly.js?version=2023.10.0" type="36da15029b380e93da54aebd-module"></script> <script src="/static/dist/standalone/loading/index.js?version=2023.10.0" type="36da15029b380e93da54aebd-module"></script> <style> :root { --ak-flow-background: url("/static/dist/assets/images/flow_background.jpg"); --pf-c-background-image--BackgroundImage: var(--ak-flow-background); --pf-c-background-image--BackgroundImage-2x: var(--ak-flow-background); --pf-c-background-image--BackgroundImage--sm: var(--ak-flow-background); --pf-c-background-image--BackgroundImage--sm-2x: var(--ak-flow-background); --pf-c-background-image--BackgroundImage--lg: var(--ak-flow-background); } /* Form with user */ .form-control-static { margin-top: var(--pf-global--spacer--sm); display: flex; align-items: center; justify-content: space-between; } .form-control-static .avatar { display: flex; align-items: center; } .form-control-static img { margin-right: var(--pf-global--spacer--xs); } .form-control-static a { padding-top: var(--pf-global--spacer--xs); padding-bottom: var(--pf-global--spacer--xs); line-height: var(--pf-global--spacer--xl); } </style>
<script src="/cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js" data-cf-settings="36da15029b380e93da54aebd-|49" defer></script><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" data-cf-beacon='{"rayId":"81c5bcebafd3e792","r":1,"version":"2023.10.0","token":"2efdb94088f04f08955a32f32a52650a"}' crossorigin="anonymous"></script>

Screenshots
image

Logs
Output of docker-compose logs or kubectl logs respectively

Version and Deployment (please complete the following information):

  • authentik version: [2023.10.1]
  • Deployment: [Unraid]

Additional context
Add any other context about the problem here.

Screenshot and info is me trying to revert back to 2023.10 with still the same issue.

I've got the same issue. Started with 10.0, cannot roll back to 10.8 unfortunately.

I found this error in the server logs (truncated for readability):

RR | event=Internal Server Error: /api/v3/flows/executor/pass-no-mfa/ exception=[{"exc_type":"ProgrammingError","exc_value":"column authentik_stages_authenticator_static_authenticatorstaticstage.token_length does not exist\nLINE 1: ...r_static_authenticatorstaticstage\".\"token_count\", \"authentik...\n       

Could it be that something went wrong during the database migration process between versions?

I fixed it by adding the missing column in the postgres DB:

alter table authentik_stages_authenticator_static_authenticatorstaticstage add column token_length INTEGER default 12;

@klutchrider @raldnor which version did you upgrade from?

I went from 2023.5.0 to 2023.10.0

So it seems the error happens when going from a version older than 2023.8 to 2023.10, as a short term solution I'll add a banner to the release notes

I now face the same issue.
For reference I came from 2023.06

Any updates on this, facing the same issues

Yeah I came from 2023.4, let me try your fix @raldnor

As stated from @raldnor, connect to your postgres DB, and try adding the table mentioned, should get you back up and running.

Thanks @BeryJu @raldnor

I came from 2023.8 and still had this issue. I ended up manually inserting the migration records into the database, oddly enough, comparing the code in the migrations against my database it appears they actually had been applied properly as all the new fields were there...

insert into django_migrations (app, name, applied) VALUES ('authentik_stages_authenticator_static', '0008_initial', current_timestamp);
insert into django_migrations (app, name, applied) VALUES ('authentik_stages_authenticator_static', '0009_throttling', current_timestamp);
insert into django_migrations (app, name, applied) VALUES ('authentik_stages_authenticator_totp', '0008_initial', current_timestamp);
insert into django_migrations (app, name, applied) VALUES ('authentik_stages_authenticator_totp', '0009_auto_20190420_0723', current_timestamp);

I was bitten by the same bug while keeping everything updated with Watchtower using the :latest tag.

For anyone who have no prior knowledge about authentik's postgres, the possible online fix is

docker-compose exec -ti -u postgres postgresql psql -U authentik
then in psql shell
alter table authentik_stages_authenticator_static_authenticatorstaticstage add column token_length INTEGER default 12;

I've tried all the fixes across the issue threads on here, now I'm finally faced with the same login page as OP, Will try joining the discord and asking there. Will report back if anything else works.

EDIT: Never mind, somehow nuked the application settings in authentik I had setup and I'm the only user using the services, so gonna nuke, try again, and make sure I actually do backups in case i have other users later on.

I came from 2023.8 and still had this issue. I ended up manually inserting the migration records into the database, oddly enough, comparing the code in the migrations against my database it appears they actually had been applied properly as all the new fields were there...

insert into django_migrations (app, name, applied) VALUES ('authentik_stages_authenticator_static', '0008_initial', current_timestamp); insert into django_migrations (app, name, applied) VALUES ('authentik_stages_authenticator_static', '0009_throttling', current_timestamp); insert into django_migrations (app, name, applied) VALUES ('authentik_stages_authenticator_totp', '0008_initial', current_timestamp); insert into django_migrations (app, name, applied) VALUES ('authentik_stages_authenticator_totp', '0009_auto_20190420_0723', current_timestamp);

this actually worked. Thank you so much. How did you know which values to introduce? u just checked which changes were propagated in the updates?