goauthentik / authentik

The authentication glue you need.
https://goauthentik.io
Other
13.73k stars 920 forks source link

ak export_blueprint fails #10421

Open cougz opened 4 months ago

cougz commented 4 months ago

Describe the bug I am unable to successfully run ak export_blueprint command in my workers command line. For other authentik instances I am running separately, it works just fine. I also noticed, that other containers do not switch to public schema when running ak export_blueprint Other commands like test email don't work either, for some reason. I'd love to switch to a new installation including new docker instance, but without the export functionality this is somewhat senseless.

To Reproduce switch to worker container run ak export_blueprint

Expected behavior a working export or backup functionality.

Screenshots If applicable, add screenshots to help explain your problem.

Logs ak export output:

authentik@7179d873fc7c:/$ ak export_blueprint {"event": "Loaded config", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540942.146156, "file": "/authentik/lib/default.yml"} {"event": "Loaded environment variables", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540942.1463258, "count": 15} {"event": "Starting authentik bootstrap", "level": "info", "logger": "authentik.lib.config", "timestamp": 1720540942.4704835} {"event": "PostgreSQL connection successful", "level": "info", "logger": "authentik.lib.config", "timestamp": 1720540942.4736266} {"event": "Redis Connection successful", "level": "info", "logger": "authentik.lib.config", "timestamp": 1720540942.4741974} {"event": "Finished authentik bootstrap", "level": "info", "logger": "authentik.lib.config", "timestamp": 1720540942.4742393} {"event": "Booting authentik", "level": "info", "logger": "authentik.lib.config", "timestamp": 1720540943.6825523, "version": "2024.6.0"} {"event": "Enabled authentik enterprise", "level": "info", "logger": "authentik.lib.config", "timestamp": 1720540943.6838663} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.6843894, "path": "authentik.enterprise.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.685123, "path": "authentik.outposts.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.68574, "path": "authentik.enterprise.providers.google_workspace.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.6860285, "path": "authentik.admin.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.6876168, "path": "authentik.sources.plex.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.6880462, "path": "authentik.events.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.6890419, "path": "authentik.enterprise.providers.microsoft_entra.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.68952, "path": "authentik.sources.oauth.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.6897697, "path": "authentik.blueprints.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.690612, "path": "authentik.sources.ldap.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.6909873, "path": "authentik.enterprise.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.6918037, "path": "authentik.crypto.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.6927204, "path": "authentik.stages.authenticator_totp.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.6930103, "path": "authentik.providers.scim.settings"} {"event": "Loaded app settings", "level": "debug", "logger": "authentik.lib.config", "timestamp": 1720540943.6935742, "path": "authentik.stages.authenticatorwebauthn.settings"} /ak-root/venv/lib/python3.12/site-packages/opencontainers/distribution/reggie/defaults.py:17: SyntaxWarning: invalid escape sequence '(' "http[s]?://(?:[a-zA-Z]|[0-9]|[$-@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+" {"domain_url": null, "event": "Loaded MMDB database", "file": "/geoip/GeoLite2-ASN.mmdb", "last_write": 1719400803.0, "level": "info", "logger": "authentik.events.context_processors.mmdb", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:24.201795"} {"domain_url": null, "event": "Loaded MMDB database", "file": "/geoip/GeoLite2-City.mmdb", "last_write": 1719400802.0, "level": "info", "logger": "authentik.events.context_processors.mmdb", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:24.202762"} {"app_name": "authentik.tenants", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.tenants.checks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.107360"} {"app_name": "authentik.tenants", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.tenants.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.107680"} {"app_name": "authentik.admin", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.admin.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.139606"} {"app_name": "authentik.admin", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.admin.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.139965"} {"app_name": "authentik.crypto", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.crypto.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.140750"} {"app_name": "authentik.flows", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.flows.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.163322"} {"app_name": "authentik.outposts", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.outposts.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.182204"} {"app_name": "authentik.outposts", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.outposts.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.182675"} {"app_name": "authentik.policies.reputation", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.policies.reputation.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.183181"} {"app_name": "authentik.policies", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.policies.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.188105"} {"app_name": "authentik.providers.proxy", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.providers.proxy.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.188494"} {"app_name": "authentik.providers.proxy", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.providers.proxy.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.188759"} {"app_name": "authentik.providers.scim", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.providers.scim.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.190065"} {"app_name": "authentik.providers.scim", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.providers.scim.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.190685"} {"app_name": "authentik.rbac", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.rbac.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.191267"} {"app_name": "authentik.sources.ldap", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.sources.ldap.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.195790"} {"app_name": "authentik.sources.ldap", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.sources.ldap.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.197006"} /ak-root/venv/lib/python3.12/site-packages/facebook/init.py:99: SyntaxWarning: invalid escape sequence '\d' version_regex = re.compile("^\d.\d{1,2}$") {"app_name": "authentik.sources.oauth", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.sources.oauth.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.202485"} {"app_name": "authentik.sources.saml", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.sources.saml.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.202801"} {"app_name": "authentik.sources.scim", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.sources.scim.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.203155"} {"app_name": "authentik.stages.authenticator_duo", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.stages.authenticator_duo.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.203520"} {"app_name": "authentik.stages.authenticator_static", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.stages.authenticator_static.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.203807"} {"app_name": "authentik.stages.authenticator_webauthn", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.stages.authenticator_webauthn.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.292237"} {"app_name": "authentik.stages.email", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.stages.email.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.292447"} {"app_name": "authentik.core", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.core.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.293639"} {"app_name": "authentik.core", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.core.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.293719"} {"app_name": "authentik.enterprise", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.enterprise.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.294003"} {"app_name": "authentik.enterprise", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.enterprise.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.294295"} {"app_name": "authentik.enterprise.providers.google_workspace", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.enterprise.providers.google_workspace.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.294708"} {"app_name": "authentik.enterprise.providers.google_workspace", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.enterprise.providers.google_workspace.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.294947"} {"app_name": "authentik.enterprise.providers.microsoft_entra", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.enterprise.providers.microsoft_entra.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.295266"} {"app_name": "authentik.enterprise.providers.microsoft_entra", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.enterprise.providers.microsoft_entra.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.295484"} {"app_name": "authentik.enterprise.providers.rac", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.enterprise.providers.rac.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.298350"} {"app_name": "authentik.events", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.events.tasks", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.298538"} {"app_name": "authentik.events", "domain_url": null, "event": "Imported related module", "level": "info", "logger": "authentik.blueprints.apps", "module": "authentik.events.signals", "pid": 424, "schema_name": "public", "timestamp": "2024-07-09T16:02:25.298602"} Switching to schema 'public' Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/manage.py", line 52, in execute_from_command_line(sys.argv) File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/init.py", line 442, in execute_from_command_line utility.execute() File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/init.py", line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv self.execute(*args, cmd_options) File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute output = self.handle(*args, *options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/authentik/tenants/management/init.py", line 38, in handle self.handle_per_tenant(args, options) File "/ak-root/venv/lib/python3.12/site-packages/django/core/management/base.py", line 107, in wrapper res = handle_func(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/authentik/blueprints/management/commands/export_blueprint.py", line 19, in handle_per_tenant self.stdout.write(exporter.export_to_string()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/authentik/blueprints/v1/exporter.py", line 73, in export_to_string return dump(blueprint, Dumper=BlueprintDumper) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ak-root/venv/lib/python3.12/site-packages/yaml/init.py", line 253, in dump return dump_all([data], stream, Dumper=Dumper, kwds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ak-root/venv/lib/python3.12/site-packages/yaml/init.py", line 241, in dump_all dumper.represent(data) File "/authentik/blueprints/v1/common.py", line 566, in represent data = asdict(data, dict_factory=factory) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dataclasses.py", line 1322, in asdict return _asdict_inner(obj, dict_factory) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dataclasses.py", line 1338, in _asdict_inner value = _asdict_inner(getattr(obj, f.name), dict_factory) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dataclasses.py", line 1366, in _asdict_inner return type(obj)(_asdict_inner(v, dict_factory) for v in obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dataclasses.py", line 1366, in return type(obj)(_asdict_inner(v, dict_factory) for v in obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dataclasses.py", line 1338, in _asdict_inner value = _asdict_inner(getattr(obj, f.name), dict_factory) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dataclasses.py", line 1375, in _asdict_inner return type(obj)((_asdict_inner(k, dict_factory), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dataclasses.py", line 1376, in _asdict_inner(v, dict_factory)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dataclasses.py", line 1375, in _asdict_inner return type(obj)((_asdict_inner(k, dict_factory), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dataclasses.py", line 1376, in _asdict_inner(v, dict_factory)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dataclasses.py", line 1366, in _asdict_inner return type(obj)(_asdict_inner(v, dict_factory) for v in obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/ak-root/venv/lib/python3.12/site-packages/rest_framework/utils/serializer_helpers.py", line 57, in init self.serializer = kwargs.pop('serializer') ^^^^^^^^^^^^^^^^^^^^^^^^ KeyError: 'serializer' Sentry is attempting to send 2 pending events Waiting up to 2 seconds Press Ctrl-C to quit

Version and Deployment (please complete the following information):

RazeLighter777 commented 4 months ago

Having this issue as well.

RazeLighter777 commented 4 months ago

Reverting to 2023.10.6 fixes the issue. I didn't bisect it completely though, newer versions may work.

ChandonPierre commented 3 months ago

Also experiencing this - I suspect this is a regression from multi-tenancy

PGimenez commented 3 months ago

Same here on 2024.6.4

BeryJu commented 2 months ago

I haven't been able to reproduce this issue on 2024.8. I'm assuming this issue only happens on a non-clean install of authentik?

authentik-automation[bot] commented 1 day ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.