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

App crashes if there is no default 'Site' #1328

Open
istride opened this issue Jul 15, 2022 · 2 comments · May be fixed by #1439
Open

App crashes if there is no default 'Site' #1328

istride opened this issue Jul 15, 2022 · 2 comments · May be fixed by #1439
Assignees
Labels
bug Something isn't working

Comments

@istride
Copy link
Contributor

istride commented Jul 15, 2022

There was an incident where a live site went down because GlobalDataMiddleware was unable to retrieve a Site object from the database, which then causes a cascade of further failures during request processing. See log attached.

The problem was resolved by ensuring that a default Site is configured i.e. at least one Site exists with the is_default_site field set to 'true'. It is unclear how there came to be no default Site in the database, but any Wagtail admin with the required permissions could create the conditions for this failure.

What can we do to try to avoid this in future?

default-site-bug.log.txt

@istride istride added the bug Something isn't working label Jul 15, 2022
@Alihassanc5 Alihassanc5 linked a pull request Oct 26, 2022 that will close this issue
@sheralim012
Copy link
Contributor

Access (add/edit/delete) to “Site” in the wagtail admin panel is controlled via permissions in groups. For example a user with no delete permission for the site.

Screenshot 2023-01-25 at 12 26 53 PM

Wagtail itself works alright if no site is available and if something relies on the site wagtail gives a descriptive message that no site is configured. For example, all sites are removed and access to “Site Settings” in the admin panel gives an error.

Screenshot 2023-01-25 at 12 27 58 PM

Just like wagtail’s “Site Settings” IoGT relies on the existence of a default site (if no default site then use the first site—not implemented right now but can be which wagtail itself uses in some places) in multiple cases, for example, registration survey, global theme, etc.

The following are possible options

  • Don’t give access to anyone for “Site”. Only superusers will have access to it. This would be difficult to manage I imagine.
  • Add help text in the "Site" admin panel that explains the repercussion of deleting a site.
  • Don’t let anyone delete the site if only one is remaining.
  • Rethink and refactor the IoGT code to handle no-site scenarios.

@istride istride assigned sheralim012 and unassigned ChrisMarsh82 Jan 25, 2023
@istride
Copy link
Contributor Author

istride commented Jan 25, 2023

I think we should be following Wagtail's lead i.e. assume that there may be no site at all and defend against that situation. Focusing first on the specific problem with GlobalDataMiddleware will fix the bug described by this issue. If there are other similar scenarios where a default site is assumed to always exist, then those should be addressed too, but maybe as a separate issue(s).

With the introduction of Wagtail Cache, it is also worth considering whether GlobalDataMiddleware is still required, and if not, then the fix might be to remove it.

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

Successfully merging a pull request may close this issue.

3 participants