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

Bulk emails include links to example.com (SITE_ID misconfiguration) #1182

Open
dyudyunov opened this issue Dec 27, 2024 · 2 comments
Open

Bulk emails include links to example.com (SITE_ID misconfiguration) #1182

dyudyunov opened this issue Dec 27, 2024 · 2 comments
Labels
bug Bugs will be investigated and fixed as quickly as possible.

Comments

@dyudyunov
Copy link

dyudyunov commented Dec 27, 2024

Bug description

Bottom line up:
Tutor installations have the SITE_ID setting pointing to the Django default example.com site while trying to avoid it.

While Tutor explicitly says that it uses SITE_ID = 2 because example.com already uses id 1, it doesn't work that way.

Actual state on any Tutor-based openedx instance I checked:

  1. We don't have a record for id == 1 at all
  2. id 2 is used by example.com
  3. The target site (the site I'm expecting on id 2) uses id 3

After a shallow investigation I found:

Consequences

For cases when the platform can't define the site (e.g., from the request), it falls back to the site with id = SITE_ID with the appropriate consequences, like bulk emails being sent without the site branding.

How to check/reproduce

Go to the LMS admin site -> Sites and check IDs for example.com and your target domain (check the record URL for ID).

You can also try to navigate to the site object with ID = 1 (<LMS>/admin/sites/site/1/):
image

Environment

Mac OS 15.0.1
Tutor >=18;<19 (Redwood)

Workarounds

  • swap sites with id 2 and 3 manually (tested)
  • change SITE_ID setting to point to id 3 (not tested, possibly will work for existing installations only)
  • add the Site Theme record in the admin site for example.com (tested with bulk emails case, works for branding, but links use incorrect domain example.com)
@regisb
Copy link
Contributor

regisb commented Dec 30, 2024

Hi,
You are describing your analysis of an issue but not clearly explaining what are the symptoms of this issue. Is the problem that bulk emails are sent without branding? If yes, please include screenshots of bulk emails before/after fix. Are there other side effects of not correctly setting SITE_ID? Then we need to know about those and document them here.

FTR I was able to confirm that SITE_ID=2 points to example.com: https://sandbox.openedx.edly.io/admin/sites/site/ But it's not clear to me what the consequences are.

I'm not sure yet what's the best solution to this problem, as I don't know for sure what the actual problem is. But in my dream world, we would not have to define SITE_ID at all in the Django setting: the value of this setting is tied to the database, which means that we need to run migrations before defining settings. But obviously, we also need to define settings to run migrations. This circular dependency should be removed, if possible.

@dyudyunov
Copy link
Author

Hi @regisb

For now, I know only about the bulk email issue, but as I said in the issue description, the case potentially affects all the functionality that needs a correct site to define branding or get site configuration values. I would search across the celery tasks for such cases.

Here is an example of a bulk email without a fix (note: the email is sent from the main site, I don't have tenants):
bulk_broken

And after the fix:
bulk_fixed

@regisb regisb changed the title SITE_ID misconfiguration Bulk emails include links to example.com (SITE_ID misconfiguration) Dec 30, 2024
@regisb regisb added the bug Bugs will be investigated and fixed as quickly as possible. label Dec 30, 2024
@DawoudSheraz DawoudSheraz moved this from Pending Triage to Backlog in Tutor project management Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs will be investigated and fixed as quickly as possible.
Projects
Development

No branches or pull requests

2 participants