Repository navigation
ci: block new /api/v1 paths in app sources - #351
Conversation
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.
|
Warning Review limit reachedNext included review available in 12 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 (4)
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 |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e8e3cfbb2
ℹ️ 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".
| allowlist="${allowlist:-${root}/scripts/ci/api-v1-allowlist.txt}" | ||
|
|
||
| scan_dirs=(iosApp/iosApp iosApp/TopShelf iosApp/NotificationService iosApp/DownloadsActivity iosApp/Tests) | ||
| pattern='api/v1|"api", *"v1"|appendingPathComponent\("v1"\)' |
There was a problem hiding this comment.
Detect multiline v1 path construction
When a request uses normal multiline Swift formatting—such as placing "api" and "v1" on adjacent array lines or placing "v1" on the line after .appendingPathComponent(—this line-oriented pattern cannot match it. I tested both forms in a new Swift file under a scanned directory; --print-counts reported nothing and the check exited successfully, so a newly added v1 request can pass CI. Normalize or tokenize the source before matching across whitespace, and add multiline cases to the guard test.
Useful? React with 👍 / 👎.
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 ( |
4e8e3cf to
ae7d6e1
Compare
21dff02 to
93cff73
Compare
The Apple clients are moving to /api/v2, but nothing stops a change from
adding a new /api/v1 request while the migration is under way.
Add scripts/ci/check-no-api-v1.sh. It scans the app, extension and test
sources for `api/v1`, `"api", "v1"` path arrays and
`appendingPathComponent("v1")`, and compares each file's count with a
ceiling in scripts/ci/api-v1-allowlist.txt, generated from the current
tree. The check fails when a count rises or an unlisted file matches, and
prints the offending lines plus the command that regenerates the
allowlist. --exact also fails on counts that dropped, for the final
cleanup. The CI scripts workflow now runs the guard and its test, and
triggers on changes to the scanned sources.
Stack-PR: F2
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
An empty allowlist made the guard pass every tree. awk's FNR == NR test never saw the allowlist as a separate file, so it read the match counts as the allowlist and compared nothing. Truncating the file with a mistyped regeneration command was enough to turn the guard off. The guard now exits 2 when the allowlist is empty or lacks its generated header, and the awk program identifies the allowlist by FILENAME instead of FNR == NR. The test covers a 0-byte and a headerless allowlist. Stack-PR: F2 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
ae7d6e1 to
ea49de8
Compare
Problem
The Apple clients are moving from
/api/v1to/api/v2across this stack. Nothing in CI stops a change from adding/api/v1requests while the migration is under way, so v1 usage can grow unnoticed.Solution
CI now fails when a file's
/api/v1match count rises above its recorded ceiling, or when a file with no ceiling starts to match.scripts/ci/check-no-api-v1.shscansiosApp/iosApp,iosApp/TopShelf,iosApp/NotificationService,iosApp/DownloadsActivityandiosApp/Testsfor three patterns:api/v1,"api", "v1"component arrays, andappendingPathComponent("v1"). It counts every occurrence, including comments.scripts/ci/api-v1-allowlist.txtrecords a ceiling per file, generated from the current tree (61 files, 524 matches). The check fails when a file's count rises above its ceiling or when an unlisted file matches. It prints the offending lines and the command to regenerate the allowlist:scripts/ci/check-no-api-v1.sh --print-counts > scripts/ci/api-v1-allowlist.txt. An empty allowlist, or one without its generated header, fails with exit code 2 instead of passing, so a truncated file (for example from a mistyped regeneration command) can't turn the guard off.--exactalso fails on dropped counts; the final cleanup PR sets the permanent allowlist (ConnectionMonitor health probe,HostedDiagnosticsAPI.swift,DiagnosticsPathTemplateTestsvectors) and switches CI to exact matching..github/workflows/ci-scripts.ymlruns the guard's test (check-no-api-v1.test.sh) and the guard. The workflow also triggers on changes under the five scanned directories.The guard uses only bash, grep, awk and sed. No Swift changes.
Validation
bash scripts/ci/check-no-api-v1.test.shpassed on macOS (bash 3.2, BSD grep/awk) and in a Debian bookworm container (GNU grep 3.8, mawk). It covers occurrence counting, skipping unscanned directories, a raised count, an unlisted file, an empty and a headerless allowlist, a lowered count with and without--exact, and the regeneration hint.scripts/ci/check-no-api-v1.shand--exactpass on this tree. In the Debian container,--print-countsreproduced the committed allowlist byte for byte.Risks and follow-ups
"v1"or the external diagnostics host'sv1/...paths inHostedDiagnosticsAPI.swift. The diagnostics host paths are deliberate.--exact, a file whose count has dropped can take new v1 paths up to its old ceiling. Comments count too, so replacing a v1 comment with a v1 call keeps the count level and passes. Review still has to catch those cases during the stack.mainat81f27dc0plus F0 and F1, which change no v1 counts). A branch that adds v1 matches before this merges will fail the guard until it regenerates 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 3 of 50 in the Apple API v2 stack. Base:
apiv2-stack/02-share-apiv2-client. Merge in order from the bottom of the stack. The plan and full index are in PR 01.🤖 Generated with Claude Code