Repository navigation
fix(connection): probe /api/v1/health without credentials - #357
Conversation
|
Warning Review limit reachedNext included review available in 9 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
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. Comment |
There was a problem hiding this comment.
Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Codex Review SummaryThis 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. |
Code review summaryReviewed head: Process: an adversarial review of this PR's diff with each candidate finding independently verified before any fix, a simplify pass for medium and larger PRs, and a whole-stack review across contract conformance, authority and failure handling, data integrity, user-visible behavior and cross-PR integration. Verified findings, all fixed on this branch:
Validation: this branch builds on its own for iOS, tvOS and macOS, and its focused tests passed. The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, the macOS build and the v1 path guard. The final stack was also exercised on iOS and tvOS simulators against a v1/v2 bridge server: sign-in (password and QR), restore, browse, search, detail, favorites and watchlist, playback (direct play, transcode, subtitles, stop), audiobooks, downloads with offline playback, settings, requests, profiles, push registration and diagnostics. Server logs showed no Remaining: no open verified findings. Merge in stack order. Mergeability: 8/10 — conditional. The approach holds up and every verified finding is fixed. Conditions: this PR's CI must pass (it was pending at review time), and the owner still plans a physical-device check of the completed stack. Review by Claude Opus 5.5 ( |
e7cd7cc to
6665e5e
Compare
0def986 to
d31bdc5
Compare
The reachability probe went through the authenticated HTTPClient.get, so it carried the bearer and profile headers. With an expired or revoked session the public health endpoint could answer 401, and the probe then started a token refresh and could end the session, all to learn whether the server was up. The probe now reads the active server's health endpoint through a new HTTPClient.getUnauthenticatedFromActiveServer, which attaches no credentials, never refreshes, and still reports the outcome to ConnectionMonitor. ConnectionMonitor keeps GET /api/v1/health as the retained unversioned probe; the doc comments now say it is sent without credentials. Stack-PR: W1-H Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
6665e5e to
fa2ad8e
Compare
The connection monitor's health probe no longer sends the bearer or profile headers, and it can no longer start a token refresh, even if something in front of the server answers it with 401.
Problem
ConnectionMonitor.probeServer()calledHTTPClient.shared.get("/api/v1/health"). That is the authenticated path: it attachedAuthorization,X-Profile-IdandX-Profile-Token, and it answered a 401 by refreshing the token. The endpoint is public, so a reachability check sent credentials it never needed.This did not cause a visible bug against the stock server. At
84ed9e596the server registersGET /api/v1/healthdirectly inr.Route("/api/v1")(router.go:2641-2642), outside everyRequireAuthgroup, so it never answers 401 there. Any HTTP response, a 401 included, already marked the server reachable (HTTPClient.performcallsnoteServerResponded()); only a transport failure marks it unreachable. The refresh risk was real only if a proxy in front of the server, or a future server, answered the probe with 401: the probe would then start a refresh, and a failed refresh could end the session.Solution
HTTPClient.getUnauthenticatedFromActiveServer(_:). It reads a public endpoint of the active server with no bearer or profile headers and no refresh. UnlikegetUnauthenticated(serverURL:…), it reports the outcome toConnectionMonitor, because the response comes from the server every other request goes to. It captures the dispatch revision before it reads the server URL, so a server switch in between rejects the probe instead of recording the old server's reachability against the new one.ConnectionMonitor.probeServer(using:)uses it. The client is injectable for tests and defaults to.shared.GET /api/v1/healthstays because it is the retained unversioned probe: the server registers it outside v2 and outside the v1 tombstone (router.goat84ed9e596). The path now lives inConnectionMonitor.healthPath.ConnectionMonitor,probeServerand theHTTPClienttype to match.Android's
HealthApi.kt:23calls a root/health, which the server does not register. Apple does not copy that.Validation
SiloTests/ConnectionMonitorProbeTests SiloTests/SettingValuesAPITests/testCandidateProbeDoesNotChangeActiveServerReachability SiloTests/RefreshSessionV2Tests) passed: 8 tests, 0 failures.SiloTVTests/ConnectionMonitorProbeTests SiloTVTests/RefreshSessionV2Tests) passed: 7 tests, 0 failures.scripts/ci/check-no-api-v1.shpassed. The v1 match count inConnectionMonitor.swiftdropped from 2 to 1: the class doc comment no longer names the path, so onlystatic let healthPathmatches. The allowlist entry stays at 2 (scripts/ci/api-v1-allowlist.txt), which the ceiling check accepts;--exactwould fail until Z1 sets that entry to 1. The new test usesConnectionMonitor.healthPathinstead of a literal.ConnectionMonitorProbeTestsstores a session and then probes. The first test's stub answers 401 to any request that carriesAuthorization, standing in for a proxy that rejects credentials. It checks that the probe sends exactly one request, with noAuthorization,X-Profile-IdorX-Profile-Tokenheader and no refresh, and that it moves the monitor from unreachable to reachable. The second checks that a transport failure marks the server unreachable.Risks and follow-ups
ItemDetailView.ServerIdentityhealth-name fallback (D8) is out of scope. W1-B deletes it.ConnectionMonitor.swiftto 1. Per the stack rules this PR does not edit the allowlist.AI disclosure
Code and description written by Claude Opus 5.5 (
claude-opus-5-5) agents in Claude Code (T3 Code), orchestrated by a Claude Code workflow.Part 9 of 50 in the Apple API v2 stack. Base:
apiv2-stack/08-refresh-through-v2. Merge in order from the bottom of the stack. The plan and full index are in PR 01.🤖 Generated with Claude Code