frappe / frappe

Low code web framework for real world applications, in Python and Javascript
https://frappeframework.com
MIT License
6.98k stars 3.32k forks source link

Magic pixel link throwing ModuleNotFound error #27461

Open joshuarestivo opened 3 weeks ago

joshuarestivo commented 3 weeks ago

Magic pixel links are not working. No messages are marked as seen. When you manually visit the magic pixel link embedded in the frappe-sourced email, an error is thrown.

To reproduce:

  1. Send an email to a Frappe Contact
  2. Look in email queue or in full copy of original email for the magic pixel link
  3. Visit link

Versions: Frappe - 15.36.0 ERPNext - 15.31.2

Error:

Traceback (most recent call last):
  File "apps/frappe/frappe/handler.py", line 74, in execute_cmd
    method = get_attr(cmd)
             ^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 287, in get_attr
    method = frappe.get_attr(cmd)
             ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1758, in get_attr
    return getattr(get_module(modulename), methodname)
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1476, in get_module
    return importlib.import_module(modulename)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'frappe.core.doctype='

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 114, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 76, in execute_cmd
    frappe.throw(_("Failed to get method for command {0} with {1}").format(cmd, e))
  File "apps/frappe/frappe/__init__.py", line 645, in throw
    msgprint(
  File "apps/frappe/frappe/__init__.py", line 610, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 561, in _raise_exception
    raise exc
frappe.exceptions.ValidationError: Failed to get method for command frappe.core.doctype=.communication.email.mark_email_as_seen with No module named 'frappe.core.doctype='
akhilnarang commented 3 weeks ago

Can you share the entire generated URL (you can hide the domain)? Something seems to be wrong in your URL.

The default URL doesn't have an = after doctype like in your error: https://github.com/frappe/frappe/blob/v15.36.0/frappe/email/doctype/email_queue/email_queue.py#L334

Do you have a custom email_tracker_read_url set in the email queue document?

cogk commented 3 weeks ago

Maybe this is related to email encoding (quoted printable)?

an equal sign at the end of a line indicates a soft line break

https://stackoverflow.com/questions/15621510/how-to-understand-the-equal-sign-symbol-in-imap-email-text/15621614#15621614

joshuarestivo commented 3 weeks ago

Here's how one of the links looks in the emai (domain elided)...

<img src=3D"https://XXX.XXXXX.com/api/method/frappe.core.doctype=
.communication.email.mark_email_as_seen?name=3Dlb418bm6er"/>

email_tracker_read_url has not been customized.

cogk commented 3 weeks ago

Okay, so the email looks correctly encoded to me… maybe the email client is incorrectly parsing the email for some reason? (cf. the link mentioned above)

joshuarestivo commented 3 weeks ago

The email client is gmail. I doubt that it’s meddling with anything. If I copy/paste the link, it gives the error. We sent about 200 messages to different recipients and not a single one shows as seen. The behavior seems consistent.

On Wed, Aug 21, 2024 at 9:07 AM Corentin Forler @.***> wrote:

Okay, so the email looks correctly encoded to me… maybe the email client is incorrectly parsing the email for some reason? (cf. the link mentioned above https://stackoverflow.com/questions/15621510)

— Reply to this email directly, view it on GitHub https://github.com/frappe/frappe/issues/27461#issuecomment-2302143736, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIYCOIIV4UY35QPGZDYS5G3ZSSNIJAVCNFSM6AAAAABM2J6CLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBSGE2DGNZTGY . You are receiving this because you authored the thread.Message ID: @.***>

joshuarestivo commented 3 weeks ago

The client is gmail so I doubt there's anything unusual going on there. Also, I'm copying and pasting the link manually and getting that error, which rules out the client. The unsubscribe link works fine, it's only the magic pixel link that throws this.

cogk commented 3 weeks ago

There might be something else inhibiting the pixel tracker, because the value sent is correctly encoded.

https://dencode.com/string/quoted-printable


What does the following report show? https:/YOUR-SITE.COM/app/communication/view/report?communication_date=["Timespan","this+quarter"]&sent_or_received=Sent&_group_by=["`tabCommunication`.`read_by_recipient`",null,"count"]