Repository navigation
fix(api): keep the base path when a request is retried against the same host - #939
Open
ANDROIDHASSAN wants to merge 1 commit into
Open
ANDROIDHASSAN wants to merge 1 commit into
ANDROIDHASSAN wants to merge 1 commit into
Conversation
…me host With no fallback region, a retryable failure is retried against the same host, but the retry URL was built from the bare origin, so a server URL with a base path got its path dropped and the retry hit a 404. Only switch the base when the retry goes to a different origin.
ANDROIDHASSAN
requested review from
changt,
cloudwebrtc,
lukasIO and
xianshijing-lk
as code owners
November 12, 2026 14:32
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This branch has not been deployed
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.
Problem: #861 made Twirp requests keep the base path of the server URL (e.g.
https://host/livekit). #811 added the same-host retry for when no fallback region exists. When that retry runs, the loop setscurrent_base = next_origin, andnext_originis the bare origin. So the retry drops the base path, posts tohttps://host/twirp/..., gets a 404, and that 404 is raised as a terminalServerError.This can happen on a Cloud API host (
cloud-api.livekit.io, which never has fallback regions) or a*.livekit.cloudhost whose region list is empty, when the URL has a base path.Fix: switch
current_originandcurrent_baseonly when the retry goes to a different origin. A same-host retry keeps the configured base. Retries to fallback regions are unchanged: they still use the region's bare origin.Tests:
test_same_host_retry_keeps_the_base_pathintests/api/test_failover_unit.py. A server serves Twirp only under/livekit, is reached ascloud-api.livekit.io, and drops the first connection. I added abase_pathargument to the existing_call_single_hosthelper for this.main:ServerError(code=unknown, message=, status=404), after the warningretrying with fallback url http://cloud-api.livekit.io:<port>.tests/api/: 34 passed, 28 skipped.ruff checkandruff format --checkare clean on both files. Includes alivekit-apipatch changeset.