Skip to content

fix: guard constructTweet against undefined full_text#1267

Merged
dimdenGD merged 1 commit into
dimdenGD:masterfrom
SAY-5:fix-construct-tweet-undefined-full-text
May 11, 2026
Merged

fix: guard constructTweet against undefined full_text#1267
dimdenGD merged 1 commit into
dimdenGD:masterfrom
SAY-5:fix-construct-tweet-undefined-full-text

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented May 11, 2026

Fixes #1252.

constructTweet reads t.full_text.length while computing the longShortClass for the body element, but the tweet object can lack a full_text property in some timeline contexts, which crashes with:

TypeError: Cannot read properties of undefined (reading 'length')
    at constructTweet (scripts/tweetConstructor.js:672:21)
    at appendTweet (scripts/helpers.js:2702:49)
    at renderTimeline (layouts/profile/script.js:1945:23)

Using t.full_text?.length ?? 0 keeps the behaviour identical for normal tweets (length compared against 280) and falls back to the short-tweet branch when full_text is missing, preserving the existing styling instead of crashing the timeline render.

The longShortClass calculation reads t.full_text.length without a
guard, throwing a TypeError when a tweet object has no full_text
property (observed in v1.9.6.5 during renderTimeline on profile
pages). Fall back to length 0 when full_text is missing so the
class assignment matches the existing short-tweet behaviour.
@dimdenGD dimdenGD merged commit dc8b575 into dimdenGD:master May 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot read properties of undefined (reading 'length') at constructTweet

2 participants