Skip to content

Error when send mail for password recover and user enroll #13232

Closed

Description

@maykosiqueira

Describe the bug
When i try enroll new user or recover the password using template flow, the message "Something went wrong! Please try again later." appears for user..

To Reproduce
Steps to reproduce the behavior:

  1. Go to default-enrollment-flow
  2. Fill all informations
  3. Press Continue
  4. See error

Expected behavior
The user was expected to be registered and receive the confirmation email.

Screenshots

Image

Logs

Traceback (most recent call last):
File "/authentik/flows/views/executor.py", line 288, in get
stage_response = self.current_stage_view.dispatch(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 143, in dispatch
return handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/authentik/stages/email/stage.py", line 154, in get
self.send_email()
File "/authentik/stages/email/stage.py", line 124, in send_email
send_mails(current_stage, message)
File "/authentik/stages/email/tasks.py", line 39, in send_mails
promise = lazy_group()
^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/celery/canvas.py", line 1584, in call
return self.apply_async(partial_args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/celery/canvas.py", line 1614, in apply_async
results = list(self._apply_tasks(tasks, producer, app, p,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/celery/canvas.py", line 1793, in _apply_tasks
sig.apply_async(producer=producer, add_to_parent=False,
File "/ak-root/venv/lib/python3.12/site-packages/celery/canvas.py", line 400, in apply_async
return _apply(args, kwargs, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/sentry_sdk/integrations/celery/init.py", line 289, in apply_async
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/celery/app/task.py", line 594, in apply_async
return app.send_task(
^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/tenant_schemas_celery/app.py", line 102, in send_task
return super(CeleryApp, self).send_task(name, args=args, kwargs=kwargs, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/sentry_sdk/integrations/celery/init.py", line 289, in apply_async
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/celery/app/base.py", line 801, in send_task
amqp.send_task_message(P, name, message, **options)
File "/ak-root/venv/lib/python3.12/site-packages/celery/app/amqp.py", line 518, in send_task_message
ret = producer.publish(
^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/sentry_sdk/utils.py", line 1783, in runner
return sentry_patched_function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/sentry_sdk/integrations/celery/init.py", line 526, in sentry_publish
return original_publish(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/kombu/messaging.py", line 175, in publish
body, content_type, content_encoding = self._prepare(
^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/kombu/messaging.py", line 268, in _prepare
body) = dumps(body, serializer=serializer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/kombu/serialization.py", line 219, in dumps
with _reraise_errors(EncodeError):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/contextlib.py", line 158, in exit
self.gen.throw(value)
File "/ak-root/venv/lib/python3.12/site-packages/kombu/serialization.py", line 45, in _reraise_errors
reraise(wrapper, wrapper(exc), sys.exc_info()[2])
File "/ak-root/venv/lib/python3.12/site-packages/kombu/exceptions.py", line 34, in reraise
raise value.with_traceback(tb)
File "/ak-root/venv/lib/python3.12/site-packages/kombu/serialization.py", line 41, in _reraise_errors
yield
File "/ak-root/venv/lib/python3.12/site-packages/kombu/serialization.py", line 220, in dumps
payload = encoder(data)
^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/kombu/utils/json.py", line 63, in dumps
return _dumps(s, cls=cls, **dict(default_kwargs, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/json/init.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/usr/local/lib/python3.12/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "/ak-root/venv/lib/python3.12/site-packages/kombu/utils/json.py", line 47, in default
return super().default(o)
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.class.name} '
kombu.exceptions.EncodeError: Object of type ModelBase is not JSON serializable

Version and Deployment (please complete the following information):

  • authentik version: 2025.2.0
  • Deployment: docker-compose

Additional context
In version 2024.12.3 it worked correctly, but with the bug reported in #13104

Activity

  1. added
    bug
    on Feb 24, 2025
  2. BerserkeR-Git commented on Feb 24, 2025

    @BerserkeR-Git

    I was just about to report on the same thing. I'm experiencing the exact same bug and get the same errors when using version 2025.2.0

    Correction:
    I see this during the password recovery flow. Emails for version updates still get sent though.

  3. trolhamonas commented on Feb 25, 2025

    @trolhamonas

    I'm getting this issue as well in the same version, but this was the first time I setup it up

  4. akdk7 commented on Feb 25, 2025

    @akdk7

    Getting the same error with version 2025.2.0. Also during password recovery flow and no mail was sent.

  5. ianr2 commented on Feb 25, 2025

    @ianr2

    I'm getting the same error with 2025.2.0 for password recovery email. Setup is using docker compose. No email gets sent. I have check on the box and sending an email outside of authentik works as expected.

  6. dgarfias commented on Feb 25, 2025

    @dgarfias

    I'm also getting this error for password recovery email.

  7. trolhamonas commented on Feb 25, 2025

    @trolhamonas
  8. dgarfias commented on Feb 25, 2025

    @dgarfias

    @melizeche Yes, and I've tried using both global settings (env vars) & manually setting the connection through the email stage

  9. melizeche commented on Feb 25, 2025

    @melizeche
    Member

    Ok, I'll try to replicate this and get back to you

  10. maykosiqueira commented on Feb 25, 2025

    @maykosiqueira
    Author

    @melizeche, yes too, in version 2024.12.3 mail service works, but the name of user most be 3 words has mentioned in #13104.
    Now, in version 2025.2.0 has a general error

  11. melizeche commented on Feb 26, 2025

    @melizeche
    Member

    I confirm this bug and have created a fix
    If you want to try this patch:

    Instructions for docker-compose

    Add the following block to your .env file:

    AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
    AUTHENTIK_TAG=gh-ab1c1c9e059cee3c34e132767e8256669bbf7a4f
    AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

    and docker-compose up -d
    Afterwards, run the upgrade commands from the latest release notes.

    Instructions for Kubernetes

    Add the following block to your values.yml file:

    authentik:
      outposts:
          container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
    global:
      image:
          repository: ghcr.io/goauthentik/dev-server
          tag: gh-ab1c1c9e059cee3c34e132767e8256669bbf7a4f

    Afterwards, run the upgrade commands from the latest release notes.

  12. dgarfias commented on Feb 26, 2025

    @dgarfias

    @melizeche I have tried running the patch and now I'm getting the following:
    ... File "/authentik/stages/email/tasks.py", line 79, in send_mail raise ValueError(f"Invalid stage class name: {stage_class_name}") ValueError: Invalid stage class name: 207e6b29-fbcf-4899-9633-ad8bdd060756 ...

    This is both using global settings and the recovery email stage

  13. cheggerdev commented on Feb 26, 2025

    @cheggerdev

    As described in #13270 I get this error on enrollment.

    So it does not matter whether it is for recovery or enrollment.

  14. rissson commented on Feb 26, 2025

    @rissson
    Member

    I have tried running the patch and now I'm getting the following: ... File "/authentik/stages/email/tasks.py", line 79, in send_mail raise ValueError(f"Invalid stage class name: {stage_class_name}") ValueError: Invalid stage class name: 207e6b29-fbcf-4899-9633-ad8bdd060756 ...

    So I've tried reproducing that, and I'm unable to do so. We think it might be due to the fact that some old task is stuck in the worker. I've tried out the changes in #13256 on a clean install, and it appears to fix the issue. We'll look into merging and releasing this as soon as possible

  15. rissson commented on Feb 26, 2025

    @rissson
    Member

    We've released the fix in 2025.2.1, could you give that a try?

  16. marked Password Recovery Failing #13280 as a duplicate of this issue on Feb 26, 2025
  17. AMDHome commented on Feb 26, 2025

    @AMDHome

    Email seems to work for me on the new 2025.2.1

    Image

  18. Spinnich commented on Feb 26, 2025

    @Spinnich

    We've released the fix in 2025.2.1, could you give that a try?

    Worked for me as well!

    Thank you so much!

  19. maykosiqueira commented on Feb 26, 2025

    @maykosiqueira
    Author

    @melizeche and @rissson now email works again!

    Thanks!

  20. dgarfias commented on Feb 27, 2025

    @dgarfias

    It's working after updating to 2025.2.1. Thank you @melizeche @rissson !!!

  21. cheggerdev commented on Feb 27, 2025

    @cheggerdev

    2025.2.1 works for me, too!

  22. Zapuskalov commented on Feb 27, 2025

    @Zapuskalov

    Doesn't solve the problem #13104

  23. rissson commented on Feb 27, 2025

    @rissson
    Member

    Doesn't solve the problem #13104

    unrelated issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions