Repository navigation
feat(profiles): list, create, verify and edit profiles through v2 - #388
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 ( |
669cc6d to
fc08eec
Compare
a6d7304 to
5453ca8
Compare
The profile picker, PIN check, new-profile form and the onboarding tour's
profile-field steps still called /api/v1/profiles, and every library list
came from /api/v1/user/libraries. The new-profile form also treated a failed
library read as "No libraries are available to assign", matched v1 error
codes that v2 no longer sends, and a wrong PIN surfaced as an expired
session.
SiloAPI now routes these calls through the shared APIv2Client methods that
already existed and are owner-fenced: GET /api/v2/profiles, POST
/api/v2/profiles (expects 201, library IDs as strings), POST
/api/v2/profiles/{id}/verify-pin, PATCH /api/v2/profiles/{id} (the
UpdateProfileBody becomes an APIv2ProfilePatch, "" language clears with
null) and GET /api/v2/user/libraries. A wrong PIN throws
ProfileTransitionError.incorrectPIN.
The new-profile form keeps a failed library read apart from an empty list
and offers Try Again. Create is non_retryable and is sent once:
CreateProfileFailure shows the server's reason for a 409 or 422, keeps the
form open for any definite failure, and closes the form for an unanswered
request so the refreshed list shows whether the profile exists. The
sent-or-not classification from PersonalStateSync moves to a shared
MutationDelivery type so both surfaces use the same rule.
LibrariesResponse is now only the cache shape, so its v1 bare-array decode
is gone. The v1 Profile and ProfilesResponse wire models are deleted.
Stack-PR: W5-E
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…nDelivery Stack-PR: W5-E Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…iscarded The owner fence can throw authorityChanged after the server already answered 201 to POST /api/v2/profiles. The form treated that as a plain failure and said "Try again", so a retry hit a name conflict or created a second profile. A 403 refusal, such as a demo-mode server, also fell through to the generic "Couldn't Create Profile" alert. An owner change now closes the form like an unanswered create, with copy that points the user at the refreshed profile list. A 403 problem shows the server's reason under "Can't Create Profile", like a 409 or 422. Stack-PR: W5-E Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
On tvOS, pressing Try Again after a failed library read swapped the focused button for a progress row, so focus jumped to another control. A retry now leaves the failed state in place and shows progress inside the button until the result arrives; repeated presses are ignored. Only the first read shows the progress row. Stack-PR: W5-E Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
MutationDelivery kept its own never-sent URLError list and treated every APIv2Error as definite, so a create answered with a 2xx other than the declared 201 kept the form open and invited a duplicate profile. It now maps from APIv2MutationOutcome: an undeclared 2xx or an unreadable answer is unconfirmed and closes the form, like a lost answer. Stack-PR: W5-E Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
fc08eec to
0fa1b3f
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Problem
Profiles and user libraries still used
/api/v1(inventory rows 26-30):SiloAPI.libraries()calledGET /api/v1/user/libraries. Every library list uses it: startup prefetch, Browse, Libraries tab, tvOS sidebar, settings and the new-profile form.SiloAPI.listProfiles()calledGET /api/v1/profilesfor the profile picker, settings, diagnostics and the current-profile store.SiloAPI.verifyProfileSelectioncalledPOST /api/v1/profiles/{id}/verify-pin.SiloAPI.createProfilecalledPOST /api/v1/profiles.SiloAPI.updateProfilecalledPUT /api/v1/profiles/{id}for the onboarding tour's profile-field steps.The new-profile form had three related problems:
try?on the library read, so a failed read showed "No libraries are available to assign."HTTPErrorcodes (profile_limit_reached,bad_request), which v2 does not send.APIError.httpError(401), so the UI said "Your session has expired."Solution
SiloAPInow calls the sharedapiV2Clientmethods that already existed. They are owner-fenced and check the status of every response:userLibraries():GET /api/v2/user/libraries. Rows map throughLibrary(v2:). A non-canonical ID fails the read instead of dropping the row.householdProfiles():GET /api/v2/profiles.verifyHouseholdPIN:POST /api/v2/profiles/{id}/verify-pin. The ID is percent-encoded.valid: falsethrows the newProfileTransitionError.incorrectPIN("That PIN is incorrect. Try again.").createHouseholdProfile:POST /api/v2/profiles. Accepts only 201. Library IDs are sent as strings, and unset members are omitted.updateProfile(id:patch:):PATCH /api/v2/profiles/{id}withUpdateProfileBody.asAPIv2Patch. The legacy""language value is sent as a clearingnull.CreateProfileView, a failed library read now shows "Couldn't load libraries" with the reason and a Try Again button. An empty list still says no libraries are available. A retry keeps the failed row and its button in place and shows progress inside the button, so focus stays on it on tvOS.CreateProfileFailurereplacesmapSubmitError. It showsproblem.detailfor 409conflict, which covers both a taken name and a full household, and for 403permission_denied, which covers a demo-mode server. For 422validation_failed, it shows the first member error. Update-required errors use the existing F5 copy.MutationDelivery(Networking) gives the create form andPersonalStateSyncone sent/never-sent/owner-changed rule. It maps from the sharedAPIv2MutationOutcome(W5-O) and keeps no transport or status lists of its own;PersonalStateSyncdrops its private classifier. One behavior change follows for favorite, watchlist and watched: an undeclared 2xx (anything other than 204) or an unreadable answer is now held as unconfirmed instead of reported as a failure. Before this, a create answered with an undeclared 2xx kept the form open and invited a duplicate profile.ProfileandProfilesResponsewire models;LibrariesResponse, which is now only theResponseCacheshape{"libraries": [...]};testLibrariesResponseDecodesBareArray.LibraryVisibilityTestsnow decodes the cache shape. Stale v1 doc comments were fixed.UpdateProfileBodyis no longerEncodablebecause nothing encodes it directly.Failure outcomes for the writes (
x-silo-retry-safetychecked incontracts/api/v2/openapi.jsonat84ed9e596):createProfile(POST)non_retryableupdateProfile(PATCH, onboarding)non_retryableverifyProfilePIN(POST)natural_idempotentvalid: true: the profile is activated with its proofvalid: falsegivesincorrectPIN; other errors surface throughErrorStateAn owner change during a call throws
HTTPError.requestIdentityChangedor.authorityChanged, and the client applies nothing under the new owner..authorityChangedcan fire after the server answered, so the server may already have applied the write. For create, the form closes and the list reloads (see the table). For the onboarding update, the step reports the error and the user can choose again.Validation
ProfilesV2Tests(new),PersonalStateSyncTests,LibraryVisibilityTests,DetailVersionSelectionTests,CatalogV2Tests,APIv2ContractTests,APIv2ProbeTestsandBrowseViewModelTests, plus the iOS-onlyOnboardingInvitationTests.ProfilesV2TestsusesStubURLProtocoland covers:LibrariesResponseshapescripts/ci/check-no-api-v1.shpassed.Risks and follow-ups
OnboardingTourAPI.updateProfile(profileId:body:)keeps its signature; only its transport changes, soOnboardingTourViewModel(moved to v2 by W5-F earlier in the stack) is untouched.PATCH /api/v2/profiles/{id}andPOST /api/v2/profilesdemo-restricted; v1'sPUT/POST /api/v1/profileswere not. On a server withdemo.enabled, a non-admin now gets a 403permission_deniedwith the detail "This action is not available in demo mode." The new-profile form shows that message. In the onboarding tour, everyprofile_fieldchoice shows the same message, and Finish fails too, because it saves the current step's default first. "Continue without saving" is the only way to finish the tour. Treating that refusal as a skipped step is an open follow-up; nothing in this stack does it. The v2 problem has no demo-specific type, so the client can recognize the refusal only as a 403permission_deniedor by its detail text.avatar_upload_enabledfromProfileCollectionis still not surfaced, as before.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 40 of 50 in the Apple API v2 stack. Base:
apiv2-stack/39-membership-v2. Merge in order from the bottom of the stack. The plan and full index are in PR 01.🤖 Generated with Claude Code