Skip to content

fix(twitter): handle missing source in broadcast stream status - #2789

Open
aloneangel45 wants to merge 1 commit into
FxEmbed:mainfrom
aloneangel45:fix/2764-broadcast-missing-stream-source
Open

aloneangel45 wants to merge 1 commit into
FxEmbed:mainfrom
aloneangel45:fix/2764-broadcast-missing-stream-source

Conversation

@aloneangel45

@aloneangel45 aloneangel45 commented Nov 26, 2026 •

Copy link
Copy Markdown

Summary

Fixes #2764.

When \live_video_stream/status\ returns an error/empty response without \source\ (or \source.location),
enderCard\ in \packages/atmosphere/src/providers/twitter/card.ts\ threw \TypeError: Cannot read properties of undefined (reading 'location')\ because it only checked \if (broadcastData).

Changes

  • Type \�roadcastData\ fields from \ witterFetch\ as optional/nullable and guard stream assignment with \if (broadcastData?.source?.location).
  • Downstream \processor.ts\ already handles an unset \�roadcast.stream\ via \card.broadcast.stream?.url ?? ''.
  • Add regression tests in \ est/api.broadcast.test.ts\ covering both v1 (/status/:id) and v2 (/2/status/:id) broadcast statuses when \live_video_stream/status\ omits \source, as well as preserving \�roadcast.stream.url\ when \source.location\ is present.

Verification


  • pm run build\ (@fxembed/atmosphere + worker esbuild) passed

  • px prettier --check test/api.broadcast.test.ts packages/atmosphere/src/providers/twitter/card.ts\ passed

  • px eslint --max-warnings=0 src/providers/twitter/card.ts\ (inside \packages/atmosphere) passed

  • px vitest run\ passed (76 test files, 502 tests)

Summary by CodeRabbit

  • Bug Fixes
    • Broadcasts now continue to load when live-stream details are unavailable or incomplete, rather than being treated as if a stream were present.
    • When a live-stream response includes a stream location, it is still used as the stream URL.
    • Verified this behavior for both supported broadcast status endpoints.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The broadcast response fields are optional, and the response may be null. Stream assignment now requires source.location. Tests cover v1 and v2 status endpoints when stream lookup returns an error, and verify that a valid stream URL is retained.

Changes: Broadcast stream response handling

Layer / File(s) Summary
Guard broadcast stream assignment and verify API responses
packages/atmosphere/src/providers/twitter/card.ts, test/api.broadcast.test.ts
The broadcast response type allows optional fields and a null response. The code sets broadcast.stream only when source.location exists. Tests cover v1 and v2 responses without a source, plus a v2 response with a source location.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: dangeredwolf

Merge Risk: Minimal · up to 68b92

Broadcast statuses should no longer fail when the live-stream response lacks a source location. The stream is omitted in that case and kept when a location exists. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title 'fix(twitter): handle missing source in broadcast stream status' matches the main change. The PR makes broadcast response fields optional and sets broadcast.stream only when source.location …
Linked Issues check Passed [#2764] The issue requires that a missing or error-shaped live_video_stream/status response must not fail the status. The diff in packages/atmosphere/src/providers/twitter/card.ts changes the response…
Out of Scope Changes check Passed The changes touch only packages/atmosphere/src/providers/twitter/card.ts (type declarations and one guard condition) and test/api.broadcast.test.ts (regression tests). Both directly implement #2764. N…
Full details: Title check

Explanation

The title 'fix(twitter): handle missing source in broadcast stream status' matches the main change. The PR makes broadcast response fields optional and sets broadcast.stream only when source.location exists, so a missing source no longer fails the status lookup. The title names the Twitter provider, the bug fixed, and the affected status path. The title is specific and describes the primary change in the changeset.

Full details: Linked Issues check

Explanation

[#2764] The issue requires that a missing or error-shaped live_video_stream/status response must not fail the status. The diff in packages/atmosphere/src/providers/twitter/card.ts changes the response type so source and its fields are optional, and the response may be null. It changes the guard from if (broadcastData) to if (broadcastData?.source?.location), which matches the suggested fix in the issue. When no location exists, broadcast.stream is not set. The card and status are still returned. The PR description reports regression tests in test/api.broadcast.test.ts for v1 and v2 endpoints with no source, and for preserving broadcast.stream.url when source.location exists. The raw summary confirms these tests. I did not read the test file. The diff does not add a try/catch around twitterFetch. If twitterFetch throws on a non-2xx HTTP response, that path would still fail. The issue's core failure (TypeError on undefined source) is fixed. The remaining uncertainty is limited to the HTTP-error transport path, which I did not inspect.

Full details: Out of Scope Changes check

Explanation

The changes touch only packages/atmosphere/src/providers/twitter/card.ts (type declarations and one guard condition) and test/api.broadcast.test.ts (regression tests). Both directly implement #2764. No unrelated behavior change appears in the reviewed card.ts diff. The console.log lines were already present and are not changed in scope.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the broadcast stream,
And skips the link when none is seen.
The status stays, the card remains,
A valid URL flows through the lanes.
The burrow cheers: the tests are green.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74600b15-5723-46fb-96ff-3420e4077897
Commits

Reviewing files that changed from the base of the PR and between f55c37f and 68b9274.

Files selected for processing: 2

  • packages/atmosphere/src/providers/twitter/card.ts
  • test/api.broadcast.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Prevents broadcast requests from crashing when Twitter omits source or source.location.

  • Twitter broadcast cards still load when stream details are missing.

Reviews (1) · Last reviewed commit: "fix(twitter): guard missing source in br..." · Reviewed by Greptile

This branch has not been deployed

No deployments
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.

Statuses with an X live broadcast return 500 ("Owie, you crashed FxTwitter") and are dropped from /2/profile/:handle/statuses

1 participant