Skip to content

feat(people): load people and refresh metadata through v2 - #384

Merged
Quick104 merged 2 commits into
mainfrom
apiv2-stack/36-people-v2
Sep 23, 2026
Merged

Quick104 merged 2 commits into
mainfrom
apiv2-stack/36-people-v2

Conversation

@Quick104

Copy link
Copy Markdown
Contributor

Problem

The person page still used v1. It read the person from GET /api/v1/people/{id} and queued metadata refreshes through POST /api/v1/people/{id}/refresh (inventory rows 56 and 57). It also stored person IDs as Int. The v2 contract declares person IDs as opaque strings, so the client should not assume integers. Today's server still issues integer IDs, so no taps are lost now; this change is forward compatibility.

Solution

  • SiloAPI.person(id:) now reads GET /api/v2/catalog/people/{id} (getPerson). SiloAPI.refreshPerson(id:) now calls POST /api/v2/catalog/people/{id}/refresh (refreshPerson). Both capture the ordinary request owner, send X-Profile-Id, percent-encode the ID through catalogPathSegment, and run inside withOwnerFence.
  • APIv2Client.catalogPerson(id:auth:) requires exactly 200 and rejects a body for a different person. APIv2Client.refreshPerson(id:auth:) requires exactly 202 with {"status":"queued","person_id":<id>} and returns nothing.
  • Person.id, Route.personDetail(personId:), APIv2CatalogQuery.personCredits(personId:) and PersonDetailViewModel now use String. The iOS and tvOS item detail screens pass the cast person_id directly instead of parsing it with Int(...).
  • Deleted: the v1 SiloAPI person methods, PersonRefreshQueuedResponse, and the unused ownerless APIv2Client.catalogPerson(id:) (F17).
  • x-silo-retry-safety for refreshPerson is non_retryable. HTTPClient.shouldAttemptRefresh already excluded this path, so a 401 is never replayed under a refreshed bearer. A regression test with a refreshable session covers this.

Failure outcomes for the person refresh (refreshPerson, non_retryable)

The page queues the refresh on its own, at most once per person, when bio, photo or birth date is missing.

Outcome Behavior
Definite success (202 queued) Poll the person every 3 s for up to 2 minutes and stop when metadata is complete or unchanged for 5 polls.
Definite failure where the read cannot queue a refresh either (404, 503 such as capability_not_configured, 400/401/403/410/422, v1-only server, owner changed before dispatch) Stop the poll, clear the refreshing indicator, log the cause, and do not retry for this person. The page keeps the person it already shows. No error UI is shown, because the user did not start this refresh.
Rejected but a refresh may still be queued (429 from the per-user limit of 10 per minute, other 5xx, a 2xx other than 202, a receipt for another person) Log it and keep polling. Viewing the person already queues a provider refresh when one is due, so the poll can still show it. The refresh is never sent again.
Uncertain (sent, no usable answer) Log it and keep polling to see whether the refresh ran. The refresh is never sent again.

Validation

  • iOS, tvOS and macOS builds passed.
  • Focused tests passed on iOS and tvOS: CatalogV2Tests, PersonMetadataRefreshPolicyTests and CatalogPagingAPITests, plus DetailDismissalNavigationTests on iOS (the class is excluded from SiloTVTests in project.yml).
  • New CatalogV2Tests cases cover:
    • encoded opaque IDs on both paths, the X-Profile-Id header, and no prefetch query parameter
    • invalid IDs, which are never sent
    • a read that returns a different person
    • one dispatch each for a problem, a 200, a wrong receipt and a timeout, with typed errors and no retry
    • a 401 on the refresh with a stored refresh token: no token refresh, no second POST, and the stored access token is unchanged (the test fails if the shouldAttemptRefresh exclusion is removed)
    • rejection when the owner is replaced before dispatch and when a late receipt arrives
  • New PersonMetadataRefreshPolicyTests check which rejected refreshes keep the read-only poll running (429, 5xx other than 503, malformed receipts) and which end it (404, 503, 400/401/403/410/422, v1-only server).
  • scripts/ci/check-no-api-v1.sh passed.
  • The final stack passed the full suites (iOS 1981 tests and tvOS 1792 tests, 0 failures), the macOS build and the v1 path guard. Every branch in the stack, this one included, builds on its own.

Risks and follow-ups

  • Nobody ran the person page against a live v2 server. The poll loop in PersonDetailViewModel has no unit test because it calls SiloAPI.shared directly. The wire layer and the keep-polling classification are covered.
  • Android stops its refresh poll on any non-success answer. Apple now keeps polling after a 429 or transient 5xx, because the page view may already have queued a refresh. This differs from Android on purpose.
  • The refresh poll still uses plain GET reads. Per the contract, a plain read also queues a provider refresh when one is due. The server decides when that is, so the poll does not send prefetch=true.
  • Issue [bug] Search does not expose actor or director results on iOS and tvOS #345 (people search) is out of scope.

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 36 of 50 in the Apple API v2 stack. Base: apiv2-stack/35-library-sections-v2. Merge in order from the bottom of the stack. The plan and full index are in PR 01.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b33296cc-92e4-42a7-bc76-a6f459853c05

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps greptile-apps 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.

Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T13:23:08.800089Z 8335d86 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Quick104

Copy link
Copy Markdown
Contributor Author

Code review summary

Reviewed head: 55e59cbc (apiv2-stack/36-people-v2).

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:

  • minor: A rejected refresh POST now stops the poll that would show the refresh the page's own GET already queued
  • minor: The "401 is not replayed under a refreshed bearer" assertion is vacuous
  • minor: The PR body's Problem section describes a user-visible bug that cannot happen against the pinned server

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 /api/v1 request from the new builds except the retained health probe.

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 (claude-opus-5-5) agents in Claude Code (T3 Code).

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 55e59cbc39

ℹ️ 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".

case .incompleteCatalogRead: return true
default: return false
}
return (200..<300).contains(status) || status == 429 || ((500...599).contains(status) && status != 503)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep polling after transient 503 responses

A 503 service_unavailable from the refresh POST is a transient failure, but this condition returns false for every 503, despite the method's stated policy of polling after transient server errors. In runMetadataAutoRefresh, that immediately ends the poll and marks the incomplete person as exhausted, so metadata potentially queued by the initial person read will not appear until the page is recreated. Distinguish the specific capability_not_configured problem identifier from other 503 responses, and keep polling for generic or undecodable 503s.

Useful? React with 👍 / 👎.

@Quick104
Quick104 force-pushed the apiv2-stack/35-library-sections-v2 branch from 278db7f to fb0a56c Compare September 23, 2026 13:19
@Quick104
Quick104 force-pushed the apiv2-stack/36-people-v2 branch from 55e59cb to 8335d86 Compare September 23, 2026 13:19
@Quick104
Quick104 force-pushed the apiv2-stack/35-library-sections-v2 branch from fb0a56c to 26bbdbb Compare September 23, 2026 13:42
Base automatically changed from apiv2-stack/35-library-sections-v2 to main September 23, 2026 13:43
Quick104 and others added 2 commits September 23, 2026 09:43
The person page still read people from /api/v1/people/{id} and queued
metadata refreshes through /api/v1/people/{id}/refresh, and it carried
person IDs as Int even though v2 sends them as opaque strings.

Load the person through GET /api/v2/catalog/people/{id} and queue the
refresh through POST /api/v2/catalog/people/{id}/refresh, both under the
captured owner with X-Profile-Id and the percent-encoded ID. Person IDs
are now strings from the cast list through the route to the credits
query, so cast taps no longer depend on Int parsing. The refresh is
non_retryable: it is dispatched once, a definite failure ends the page's
refresh poll, and a lost answer is observed by re-reading the person
without dispatching again. The v1 methods, PersonRefreshQueuedResponse
and the unused ownerless catalogPerson(id:) are deleted.

Stack-PR: W5-J
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A rejected refresh POST ended the person page's poll at once. Viewing a
person already queues a provider refresh when one is due, so a 429 from
the per-user refresh limit, or a transient server error, left a refresh
running that the page never showed. The 401 regression test was also
vacuous: its fixture stored no refresh token, so it passed even without
the non_retryable path exclusion.

The poll now keeps running without dispatching again after a 429, a 5xx
other than 503, or a malformed receipt. It still stops when the read
cannot queue a refresh either: 404, 503, a refused credential, request
or client, or a v1-only server. The 401 test now seeds a refreshable
session and asserts no token refresh, no second POST and an unchanged
access token.

Stack-PR: W5-J
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Quick104
Quick104 force-pushed the apiv2-stack/36-people-v2 branch from 8335d86 to 9d378b3 Compare September 23, 2026 13:43
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Quick104
Quick104 merged commit 628ccf0 into main Sep 23, 2026
3 of 6 checks passed
@Quick104
Quick104 deleted the apiv2-stack/36-people-v2 branch September 23, 2026 13:43
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.

1 participant