Skip to content

Keep Twitch ingest urls when the ingest list is unavailable - #1475

Open
RaphaelFakhri wants to merge 1 commit into
livekit:mainfrom
RaphaelFakhri:fix/twitch-ingest-url-fallback
Open

RaphaelFakhri wants to merge 1 commit into
livekit:mainfrom
RaphaelFakhri:fix/twitch-ingest-url-fallback

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

Problem

For an RTMP url that points at a Twitch ingest server (rtmp(s)://*.contribute.live-video.net/app/{stream_key}), ValidateUrl rewrites the url with the template from https://ingest.twitch.tv/ingests. If that request fails, the url is meant to be used as given. Since the stream logic cleanup in #754, parsed is only assigned on success, so it stays empty and redactStreamKey("") rejects the request with:

invalid url rtmp://lax.contribute.live-video.net/app/<key>: rtmp urls must be of format rtmp(s)://{host}(/{path})/{app}/{stream_key}( live=1)

The url is valid and works without the rewrite, but the egress, or the UpdateStream call that adds it, fails whenever the egress host cannot reach the Twitch ingest list. GetStream has the same dependency and returns the http error, so the url cannot be removed with UpdateStream either.

Change

  • ValidateUrl starts from the raw url for Twitch ingest urls and replaces it only when the ingest template is available, as it did before Clean up stream logic #754.
  • GetStream resolves Twitch ingest urls the same way, so a stream added from the raw url can still be found and removed.

twitch:// urls are unchanged: they have no server to fall back to, so they still return the error.

Testing

TestTwitchEndpointWithoutIngestList makes the ingest list request fail, then validates, adds and looks up a Twitch ingest url. Without the fix it fails with the error above. With the fix it passes.

go test ./pkg/config -run 'TestTwitchEndpointWithoutIngestList|TestValidateUrl|TestGetUrl' -v

Fixes #1474

@RaphaelFakhri
RaphaelFakhri requested a review from a team as a code owner October 21, 2026 08:09

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment thread pkg/config/urls.go
Comment on lines +142 to 145
parsed = rawUrl
if updated, err := o.updateTwitchURL(match[1]); err == nil {
parsed = updated
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Twitch stream removal fails after recovery

When the ingest list recovers after a raw URL was added, GetStream rewrites that URL before lookup. AddStream stored the raw URL while the list was unavailable, so UpdateStream cannot remove the running stream.

Learn more

A stream is stored in Streams under its parsed URL by AddStream. During an ingest-list outage, the new fallback uses the original URL as that key. Once the list recovers, GetStream resolves the same URL to the ingest template and looks up a different key. UpdateStream then reports stream not found and leaves the output running.

Example: Add rtmp://lax.contribute.live-video.net/app/key during an outage; it is stored under that exact URL. When the ingest list becomes available and selects rtmps://other.contribute.live-video.net/app/{stream_key}, removing the original URL looks for rtmps://other.contribute.live-video.net/app/key instead.

Recommended fix: Preserve a stable mapping from submitted URLs to stored streams, or check for a stored raw URL before attempting the ingest rewrite in GetStream. Test the outage-to-recovery transition using a controlled HTTP transport.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

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.

Twitch ingest urls are rejected when the Twitch ingest list cannot be fetched

1 participant