fix: add error handling to populateAuthors #10652
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
While setting up a Payload project using the following steps:
pnpx create-payload-app@latest.websiteMongoDByarn dev.The application successfully initializes with default posts and pages. However, an issue arises when navigating to pages in both normal preview and live preview after removing all users except the one created during setup. The following error is displayed:

Problem
Upon investigation, the issue stems from the
populateAuthors.tsfile. Payload does not currently handle the case where a deleted user is still referenced in posts. This causes a failure when attempting to interact with the pages, especially when adding an archive block.Since I'm new to Payload, I reviewed the seed files but couldn't identify any related issues. Additionally, I couldn't find a similar issue reported in the existing PRs.
Solution
I added error handling in the
populateAuthors.tsfile to gracefully manage cases where a deleted user is referenced. After implementing this fix, the application no longer crashes, and the pages render correctly.Updated behavior:

Request for Review
Please let me know if I’ve missed anything or if there are additional steps I should take to ensure this fix aligns with the Payload project’s conventions.