Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email cannot locate icon_left_brand.png #12969

Open
gerberbrett opened this issue Feb 9, 2025 · 4 comments
Open

Email cannot locate icon_left_brand.png #12969

gerberbrett opened this issue Feb 9, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@gerberbrett
Copy link

Describe the bug
When sending emails either using email stage or the "ak test_email" function in the shell a System task exception is logged with the following error:
builtins.FileNotFoundError: [Errno 2] No such file or directory: 'web/dist/assets/icons/icon_left_brand.png'

To Reproduce

  1. Email enrollment flow was created by following the youtube video https://www.youtube.com/watch?v=mGOTpRfulfQ&t=13s
  2. A new user was then created using the "Need an account? Sign Up." Link
  3. Shortly after completion of the signup process, a System task exception is logged with the following:
  4. Task send_mail encountered an error: Traceback (most recent call last):
    File "/usr/local/lib/python3.12/site-packages/celery/app/trace.py", line 453, in trace_task
    R = retval = fun(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/celery/app/trace.py", line 736, in protected_call
    return self.run(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/celery/app/autoretry.py", line 60, in run
    ret = task.retry(exc=exc, **retry_kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/celery/app/task.py", line 736, in retry
    raise_with_context(exc)
    File "/usr/local/lib/python3.12/site-packages/celery/app/autoretry.py", line 38, in run
    return task._orig_run(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/authentik/stages/email/tasks.py", line 105, in send_mail
    raise exc
    File "/usr/local/lib/python3.12/site-packages/authentik/stages/email/tasks.py", line 86, in send_mail
    message_object.attach(logo_data())
    ^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/authentik/stages/email/utils.py", line 20, in logo_data

    path = Path("/opt/authentik/web/dist/assets/icons/icon_left_brand.png")

          ^^^^^^^^^^^^^^^^
    

builtins.FileNotFoundError: [Errno 2] No such file or directory: 'web/dist/assets/icons/icon_left_brand.png'

Expected behavior
Expect and email to be sent without exceptions.

Screenshots

Image

Logs
This is a "bare metal" installation on a Proxmox LXC container so no "Docker" or "Kubernetes" logs are avaialble.

Version and Deployment (please complete the following information):

  • authentik version: [e.g. 2024.12.3]
  • Deployment: [Bare Metal using Proxmox VE Helper-Scripts, https://community-scripts.github.io/ProxmoxVE/scripts?id=authentik]

Additional context
Add any other context about the problem here.

@gerberbrett gerberbrett added the bug Something isn't working label Feb 9, 2025
@dominic-r
Copy link
Contributor

dominic-r commented Feb 10, 2025

@gerberbrett Proxmox LXC is not a supported installation method. This issue has not yet been reported on K8s or docker installations which leads me to believe this issue is related to your setup

You could try finding the correct file and moving it to the expected file path or you could attempt to create a new brand/flow/stage with updated paths. I haven't really looked into what that guide says

@joaorgoncalves
Copy link

I'm running into the same error message. The curious point here is that 3 days ago, I installed Authentik in Proxmox, did the email setup and it worked perfectly. Then I had to reinstall it today, exactly the same setup, and I got the error message this time.

The file exists in the folder mentioned in the log. It's just on the absolute path /opt/authentik/web/dist/assets/icons/icon_left_brand.png

Image

Relative to the utils.py script, it would be located at ../../web/dist/assets/icons/icon_left_brand.png

Do you think it has anything to do with it?

I don't see any relevant releases between then and now that could have changed anything unless some dependency changed.
I'll continue to search for an answer

@joaorgoncalves
Copy link

Update:
The utils.py file is not getting the right path:

"""email utils"""

from email.mime.image import MIMEImage
from functools import lru_cache
from pathlib import Path

(...)

@lru_cache
def logo_data() -> MIMEImage:
    """Get logo as MIME Image for emails"""
    path = Path("web/icons/icon_left_brand.png")
    if not path.exists():
        path = Path("web/dist/assets/icons/icon_left_brand.png")
    with open(path, "rb") as _logo_file:
        logo = MIMEImage(_logo_file.read())
    logo.add_header("Content-ID", "logo.png")
    return logo

(...)

Adding a print(path) line after the path = Path("web/icons/icon_left_brand.png") line will return web/icons/icon_left_brand.png

Something on the Path function from the pathlib is not working correctly.

What I did was change the path = Path("web/dist/assets/icons/icon_left_brand.png") to path = Path("/opt/authentik/web/dist/assets/icons/icon_left_brand.png") and it works now.

It is not a great solution but a quick fix for it to work right away 🤷‍♂

@gerberbrett
Copy link
Author

@joaorgoncalves Thanks, that worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants