Repository navigation
refactor(networking): delete the v1 transport - #398
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 ( |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca8bdb6035
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else if ($2 + 0 > allowed[$1]) { | ||
| printf "OVER\t%s\t%d\t%d\n", $1, $2, allowed[$1] | ||
| } else if (exact && $2 + 0 < allowed[$1]) { | ||
| } else if ($2 + 0 < allowed[$1]) { | ||
| printf "UNDER\t%s\t%d\t%d\n", $1, $2, allowed[$1] |
There was a problem hiding this comment.
Pin the allowed v1 route, not only its count
When an allowed occurrence is replaced rather than added—most importantly, if ConnectionMonitor.healthPath changes from /api/v1/health to another v1 endpoint—the count remains 1, so this comparison reports no difference. The DEBUG predicate and HTTPClientRequestPathTests also trust that same constant, meaning CI, runtime assertions, and tests would all accept the forbidden route even though the health probe is documented as the sole exception. Pin the production exception's matched text or independently assert the literal health path.
Useful? React with 👍 / 👎.
ca8bdb6 to
d1df5f8
Compare
844efc1 to
2cd4e12
Compare
Every Silo request now goes through /api/v2 except the retained
unauthenticated health probe, but HTTPClient still carried the v1-era
JSON verbs, the v1 error envelope parsing and wire models with no
production caller, and the /api/v1 guard only enforced a ceiling.
Delete HTTPClient's post, postVoid, put, putVoid, patch, patchVoid,
delete, postRaw, putRaw and postMultipart with the send/sendRaw helpers,
the JSON request-body encoding and HTTPError.encodingFailed they alone
used, the v1 `{error, message}` envelope parsing (serverErrorCode), the
v1 profile error codes in StartupContentPrefetcher, AuthUser and
ImpersonationInfo, and APIv2Client.requestPost. UpdateRequirement keeps
recognising the tombstone envelope, which only the health probe can
still receive.
Add a DEBUG assertion in HTTPClient's request builder: a Silo server
route must be a /api/v2 operation or ConnectionMonitor.healthPath.
Rewrite the stale v1 comments, move test inputs to v2 routes, make the
guard exact in both directions and set the allowlist to its final
state.
Stack-PR: Z1
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…rror fixture The isSiloServerPath doc said only hosted diagnostics and media URLs bypass HTTPClient's request builder, but TopShelfHTTPClient, PairingDeviceAPI, the download file URL, the control socket handshake and the push display URL also build server URLs themselves. The HTTPClient type doc and the perform() call-site list still described the deleted post, raw and multipart verbs and JSON body encoding. The PlaybackV3 error_response.json fixture lost its only test and is the retired v1 426 envelope. Name every builder the DEBUG assertion does not cover, describe the remaining verbs and the refresh-only encoder, delete the fixture and record in PlaybackV3/SOURCE why it is not vendored. Stack-PR: Z1 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
d1df5f8 to
6c076a5
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
The Apple clients now send only
/api/v2requests plus the unauthenticatedGET /api/v1/healthprobe, and the leftover v1 transport is deleted. A DEBUG assertion and an exact CI guard keep it that way.Problem
After the earlier PRs in this stack, every request from the Apple clients goes to
/api/v2except the retained, unauthenticatedGET /api/v1/healthprobe (ConnectionMonitor.healthPath). Leftover code still made v1 calls look possible:HTTPClientstill had the v1-era JSON verbs (post,postVoid,put,putVoid,patch,patchVoid,delete,postRaw,putRaw,postMultipart) and theirsend/sendRaw/sendRawBodyhelpers. None had a production caller.HTTPErrorstill parsed the v1{error, message}error envelope.StartupContentPrefetcherstill matched the v1 profile codesprofile_unverifiedandprofile_not_found.AuthUserandImpersonationInfoand the unusedAPIv2Client.requestPostwere still in the tree./api/v1routes./api/v1guard only enforced a ceiling, so a removed v1 path could stay in the allowlist.Solution
HTTPClientverbs and helpers. Also deleted the JSON request-body encoding (AnyEncodable,EmptyResponse) andHTTPError.encodingFailed, which only those verbs used.getis now a single path-only method; its two production callers pass no query. Removed.encodingFailedfrom the eight exhaustive switches that listed it.multipartBody,requestData,getUnauthenticated*,getWithBearerandrevokeSessionstay because they have production callers.HTTPError.serverErrorCodeand the v1messagedisplay. Non-2xxHTTPError.httpnow reads "Server returned status N" unless the response is the client-upgrade 410. v2 problem bodies have nomessagefield, so v2 errors show the same text as before.UpdateRequirementstill recognizes the v1 tombstone envelope{"error":"client_upgrade_required"}through a private decoder, because the health probe is the one request that can still receive it.StartupContentPrefetcher.indicatesInvalidProfilenow recognizes only the v2profile_verification_requiredproblem.AuthUser,ImpersonationInfoandAPIv2Client.requestPost, plus therequestPostcase in theCatalogV2Testsfence test. I11 check: grepped for bare, inferred-case (.encodingFailed), trailing-closure and#ifuses before each deletion. All three platform builds confirm no uses remain.HTTPClient.buildRequestnow callsassertionFailurein DEBUG builds when the route is neither/api/v2(exactly, or followed by/) norConnectionMonitor.healthPath. The check reads the route argument, not the final URL, so servers mounted under a base path still pass. The assertion covers only requestsHTTPClientbuilds. Token refresh builds its URL separately, from the constant/api/v2/auth/refresh. These builders join routes onto the server URL themselves and are not checked:TopShelfHTTPClient,PairingDeviceAPI,APIv2Client.downloadFileURL, the playback control socket handshake andApplePushDisplayMetadata.HostedDiagnosticsAPI(external host) and server-minted absolute media URLs are not checked either. The CI guard below covers literal v1 paths in all of them.healthPathis nownonisolatedso the nonisolated predicate can read it./api/v1doc comments inHTTPClient(route normalization, the refresh-retry log example, the dotted-segment example), theHTTPClienttype doc and theperform()call-site list that named the deleted verbs and body encoding, andAuthModels, plus the stale "v1 paths keep working" note inAuthServiceand the "pilot" wording inAPIv2Probe.MediaRequestAuthorizationTests,MediaAuthorizationPlaybackTests,RefreshSessionV2Tests,UpdateRequirementTests,DiagnosticsRedactionTestsand theStubURLProtocolusage example. Tests that usedpostVoidnow userequestData, which takes the same ordinary refresh path. The health-probe tests inSettingValuesAPITestsnow useConnectionMonitor.healthPath. RewroteInvalidProfileRecoveryTests(inProfileLaunchPolicyTests.swift) for the v2 problem, and deleted the v1 426 envelope test inPlaybackProtocolV3ConformanceFixtureTeststogether with its only input, the vendoredPlaybackV3/error_response.json.PlaybackV3/SOURCEnow lists six vendored files and says whyerror_response.jsonis not vendored. AddedHTTPClientRequestPathTestsfor the assertion's predicate, including the base-path case.scripts/ci/check-no-api-v1.shis now exact: it fails when any file's count is above or below its allowlist entry, and when an unlisted file matches. The--exactflag is removed because exact matching is now the only mode. The script's test covers removals and lowered counts. The final allowlist has one production file,ConnectionMonitor.swift(the health path). The other entries areDiagnosticsPathTemplateTests(templating vectors),APIv2ProbeTestsandHTTPClientRequestPathTests(tests that assert v1 is never requested), and two vendored fixtures (DiagnosticsContractloglines andSettingsContract/SOURCE).HostedDiagnosticsAPI.swifthas no entry because its external/v1/...host paths do not match theapi/v1pattern.docs/native-api-v2.mdnow says the health probe is the only v1 request and names the assertion and the guard that enforce it.sites.tsvsweep. The only production/api/v1match isConnectionMonitor.healthPath(row 10, retained). Production has no"api", "v1"orappendingPathComponent("v1")construction.git grep -n '"v1"\|appendingPathComponent("v1")' -- iosAppfinds only test ETags and video keys. No other row, including E1 and E2, still has production code.Validation
SWIFT_ACTIVE_COMPILATION_CONDITIONSincludesDEBUG), so the new assertion was live, and no test sent a route outside/api/v2or the health path.bash scripts/ci/check-no-api-v1.test.shpasses, andbash scripts/ci/check-no-api-v1.shpasses in exact mode.PlaybackProtocolV3ConformanceFixtureTests,PlaybackProtocolV3TestsandHTTPClientRequestPathTestspass (78 tests each, 0 failures).Risks and follow-ups
HTTPError.httpwhose body used the v1messagefield no longer shows that message. Only v1 routes sent that shape, and the client no longer calls them.withOwnerFence/sameCredentialIdentityiniosApp/iosApp) drops from 68 to 67 on the stacked branch. The removed line was the fence inside the deletedrequestPost, which had no production caller, so no live path lost a fence.UpdateRequirementstill accepts both.OnboardingSettingOption,RequestTarget) are v1 leftovers. They are referenced by live v2 models, so this PR keeps them.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 50 of 50 in the Apple API v2 stack. Base:
apiv2-stack/49-diagnostics-uploads-v2. Merge in order from the bottom of the stack. The plan and full index are in PR 01.🤖 Generated with Claude Code