Skip to content

fix: handle missing entity fields from X syndication API#219

Open
7IBO wants to merge 1 commit into
vercel:mainfrom
7IBO:fix/handle-missing-entity-fields
Open

fix: handle missing entity fields from X syndication API#219
7IBO wants to merge 1 commit into
vercel:mainfrom
7IBO:fix/handle-missing-entity-fields

Conversation

@7IBO
Copy link
Copy Markdown

@7IBO 7IBO commented May 22, 2026

Problem

The X syndication API omits entities.hashtags, .user_mentions, .urls, and .symbols when a tweet has none of those entities, instead of returning empty arrays. This causes getEntities() to pass undefined to addEntities(), which crashes with:

TypeError: entities is not iterable

This affects any tweet that has no hashtags, mentions, URLs, or symbols (e.g. text + image only tweets).

Example tweet that reproduces the issue: https://x.com/RiotPhroxzon/status/2056998824779079835

Response from the syndication API for this tweet:

"entities": {
  "media": [{ ... }]
}

Note the absence of hashtags, user_mentions, urls, and symbols fields.

Fix

  • Add ?? [] fallback when passing entity arrays to addEntities() in getEntities()
  • Add default parameter value entities: TweetEntity[] = [] in addEntities() as an additional safety net

Fixes #218

The X syndication API omits `entities.hashtags`, `.user_mentions`,
`.urls`, and `.symbols` when a tweet has none of those, instead of
returning empty arrays. This causes `getEntities` to pass `undefined`
to `addEntities`, which crashes with `TypeError: entities is not
iterable` in the `for...of` loop.

Add `?? []` fallback in `getEntities` and a default parameter value
in `addEntities` to handle the missing fields gracefully.

Fixes vercel#218
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 22, 2026

@7IBO is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

Bug: entities is not iterable error when rendering tweets where entities is an object (not an array)

1 participant