General Improvements: Skip invalid pages that fail to load
- Dominant language
- Elixir
- Stars
- 1.3k
- Forks
- 134
- PR merge metrics
- No merged PRs in 30d
Description
We do [validate templates](https://github.com/BeaconCMS/beacon/issues/74) and resources as much as possible but that's not enough since we expose a [callback to customize template loading](https://github.com/BeaconCMS/beacon/blob/cbe3bf7445cc559c96310593105e710366ed2cea/lib/beacon/config.ex#L90) that may fail due to user errors, causing crashes that take the whole site down. Since the pages are lazy loaded, we can't perform checks early in the pipeline being open to such risk.
Now that we support [error pages](https://github.com/BeaconCMS/beacon/pull/331), we'll skip loading such pages and let beacon present a 404 error instead.
So instead of just raising when loading a page at https://github.com/BeaconCMS/beacon/blob/cbe3bf7445cc559c96310593105e710366ed2cea/lib/beacon/loader.ex#L448
it will insert a new record in a ETS table storing the page id as key and both the stack trace and exception as value.
This ETS has to be created when the app starts, similar to https://github.com/BeaconCMS/beacon/blob/4d29550c86235e8866f90971e6c5ac96a7fac3a9/lib/beacon/application.ex#L19 and it will look like this:
```
Table name: beacon_failed_pages
```
| page_id | reason |
| -------- | ------- |
| uuid | {exception, stack_trace }
Having such feature allow us to [display what caused the page to fail](https://github.com/BeaconCMS/beacon_live_admin/issues/90).
Related to https://github.com/BeaconCMS/beacon/pull/35 and https://github.com/BeaconCMS/beacon_live_admin/issues/90
Contributor guide
Research direction
Start by reading the page-loading failure path around lib/beacon/loader.ex#L448 and the application startup setup around lib/beacon/application.ex#L19. Trace how lazy page loading reports failures, then verify that beacon_failed_pages is initialized at startup, invalid pages are skipped with a 404, and the page ID, exception, and stack trace are retained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100