Don't crash on the first post of a user created by /localnewuser - #22
Open
courtneyr-dev wants to merge 1 commit into
Open
Don't crash on the first post of a user created by /localnewuser#22courtneyr-dev wants to merge 1 commit into
courtneyr-dev wants to merge 1 commit into
Conversation
A user created through /localnewuser has never called /saveprefs, so
their prefs column is NULL and convertUser hands back a record with no
prefs at all. The first post then takes the whole server down:
TypeError: Cannot read properties of undefined (reading 'myFeedTitle')
at buildFeedForUser (rssnetwork.js:1144)
because buildFeedForUser (and getUserData) read userRec.prefs.myFeedTitle
without a guard. Default prefs to an empty object in convertUser, the one
place user rows are converted, so every reader sees the same shape.
To reproduce on a fresh server: /localnewuser, then /newpost. With this
change the post publishes and the feed builds with the fallback title.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A user created through
/localnewuserhas never called/saveprefs, so their prefs column is NULL andconvertUserhands back a record with noprefsmember. Their first/newpostthen takes the whole server down:To reproduce on a fresh server:
/localnewuser, then/newpost.One line: default
prefsto an empty object inconvertUser, the one place user rows are converted, sobuildFeedForUserandgetUserDataalways see the same shape. Verified on a fresh SQLite server: the post publishes, the feed builds with the fallback title, no crash.🤖 Generated with Claude Code