Repository navigation
Harden diagnostics PII redaction - #99
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughDiagnostics snapshots and artifacts now omit device identifiers and general OSLog entries. Redaction covers additional URL and JSON secret formats, HTTP errors use safe descriptions, recent sessions expire, and application logs remove sensitive values. ChangesDiagnostics redaction and retention
Privacy-safe logging and metadata cleanup
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
- Remove URLs, identifiers, credentials, and response bodies from logs and snapshots - Limit diagnostic bundles to the allowlisted ring and purge stale session data - Add coverage for secret formats, IPv6 URLs, device identity, and expiry
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
iosApp/Tests/DeviceSnapshotBuilderTests.swift (1)
47-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the failable UTF-8 conversion required by SwiftLint.
Proposed fix
- let encoded = String(decoding: data, as: UTF8.self) + let encoded = try XCTUnwrap(String(data: data, encoding: .utf8))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/Tests/DeviceSnapshotBuilderTests.swift` around lines 47 - 48, Update the encoded string conversion in the snapshot encoding test to use Swift’s failable UTF-8 initializer instead of String(decoding:as:). Preserve the existing encoded data flow and handle the initializer’s failure appropriately within the test.Source: Linters/SAST tools
iosApp/iosApp/Screens/Player/AVPlayerRoute/AVPlayerBackend.swift (1)
1431-1436: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winClamp
firstFrameMsto non-negative for consistency withPlayerCore.swift.
PlayerCore.swiftclamps the equivalent first-frame elapsed time withmax(0, ...)at the call site (line 5364), but this callback path does not. Since both feed the sameonFirstFramecontract and the same[CMP-TTFF]-style telemetry, an unclamped negative value here (e.g., from a load-anchor edge case) would produce an inconsistent/confusing log line even though the downstreamreportProtocolV3FirstFrameclamps it before emitting the V3 event.🩹 Proposed fix
- let firstFrameMs = ttffElapsedMs() + let firstFrameMs = max(0, ttffElapsedMs())🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Player/AVPlayerRoute/AVPlayerBackend.swift` around lines 1431 - 1436, Clamp the elapsed value assigned to firstFrameMs in the AVPlayer first-frame callback to a minimum of zero, matching the existing PlayerCore.swift behavior. Pass this clamped value to onFirstFrame and use it in the [CMP-TTFF] telemetry log.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@iosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift`:
- Around line 431-441: Update the capability-probe error handling in
startProtocolV3IfAvailable so failures other than HTTP 404/405 also return nil
and allow startSession to continue through the legacy /playback/start path.
Treat unexpected errors as unavailable for the current attempt, while leaving
protocolV3Available unresolved so a later retry can probe again.
In `@iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift`:
- Line 59: Resolve the redundant ternary in the capabilities construction by
confirming whether mpeg2video needs a distinct decoder value; if not, replace
the codec-dependent expression with the literal "VideoToolbox". Update the
decoderName assignment in the relevant Apple playback capability code while
preserving the intended reported decoder.
---
Nitpick comments:
In `@iosApp/iosApp/Screens/Player/AVPlayerRoute/AVPlayerBackend.swift`:
- Around line 1431-1436: Clamp the elapsed value assigned to firstFrameMs in the
AVPlayer first-frame callback to a minimum of zero, matching the existing
PlayerCore.swift behavior. Pass this clamped value to onFirstFrame and use it in
the [CMP-TTFF] telemetry log.
In `@iosApp/Tests/DeviceSnapshotBuilderTests.swift`:
- Around line 47-48: Update the encoded string conversion in the snapshot
encoding test to use Swift’s failable UTF-8 initializer instead of
String(decoding:as:). Preserve the existing encoded data flow and handle the
initializer’s failure appropriately within the test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1f14c81e-0a35-477b-9b95-c1a4d9a2b108
⛔ Files ignored due to path filters (6)
iosApp/Tests/Fixtures/v3_h264_aac.m4vis excluded by!**/*.m4viosApp/Tests/Fixtures/v3_h264_aac.mkvis excluded by!**/*.mkviosApp/Tests/Fixtures/v3_h264_aac.movis excluded by!**/*.moviosApp/Tests/Fixtures/v3_h264_aac.mp4is excluded by!**/*.mp4iosApp/Tests/Fixtures/v3_mpeg4_mp3.aviis excluded by!**/*.aviiosApp/Tests/Fixtures/v3_vp9_opus.webmis excluded by!**/*.webm
📒 Files selected for processing (39)
iosApp/Tests/DeviceSnapshotBuilderTests.swiftiosApp/Tests/DiagnosticsPIIRedactionTests.swiftiosApp/Tests/DiagnosticsReviewFixesTests.swiftiosApp/Tests/Fixtures/v3_h264_aac.m2tsiosApp/Tests/Fixtures/v3_h264_aac.m3u8iosApp/Tests/Fixtures/v3_h264_aac.tsiosApp/Tests/Fixtures/v3_hls_00.tsiosApp/Tests/Fixtures/v3_hls_01.tsiosApp/Tests/PlaybackMediaFixtureTests.swiftiosApp/Tests/PlaybackProtocolV3Tests.swiftiosApp/iosApp/Components/MediaRow.swiftiosApp/iosApp/ContentView.swiftiosApp/iosApp/Control/iOS/SiloControlClient.swiftiosApp/iosApp/Downloads/DownloadFilePaths.swiftiosApp/iosApp/Downloads/DownloadManager.swiftiosApp/iosApp/Networking/ContinuumAPI.swiftiosApp/iosApp/Networking/HTTPClient.swiftiosApp/iosApp/Networking/ServerRegistry.swiftiosApp/iosApp/Pairing/Companion/CompanionPairingCoordinator.swiftiosApp/iosApp/Pairing/Receiver/ReceiverPairingCoordinator.swiftiosApp/iosApp/Screens/Detail/Phone/PhoneHeroMetadata.swiftiosApp/iosApp/Screens/Player/AVPlayerRoute/AVPlayerBackend.swiftiosApp/iosApp/Screens/Player/AVPlayerRoute/LoopbackSegmentStore.swiftiosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swiftiosApp/iosApp/Screens/Player/NowPlayingController.swiftiosApp/iosApp/Screens/Player/PlaybackSessionBridge.swiftiosApp/iosApp/Screens/Player/PlayerViewModel.swiftiosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swiftiosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3PlanAdapter.swiftiosApp/iosApp/Screens/Player/ProtocolV3/PlaybackProtocolV3Models.swiftiosApp/iosApp/Shared/Diagnostics/DeviceSnapshotBuilder.swiftiosApp/iosApp/Shared/Diagnostics/DiagnosticsCoordinator.swiftiosApp/iosApp/Shared/Diagnostics/Logging/DiagLog.swiftiosApp/iosApp/Shared/Diagnostics/RecentSessionTracker.swiftiosApp/iosApp/tvOS/Screens/Detail/TVDetailHero.swiftiosApp/iosApp/tvOS/Screens/Detail/TVExpandableSynopsis.swiftiosApp/iosApp/tvOS/Screens/Detail/TVMovieDetailView.swiftiosApp/iosApp/tvOS/Screens/Detail/TVSeasonDetailView.swiftiosApp/iosApp/tvOS/Screens/Detail/TVSeriesDetailView.swift
💤 Files with no reviewable changes (5)
- iosApp/iosApp/Shared/Diagnostics/DeviceSnapshotBuilder.swift
- iosApp/iosApp/Screens/Detail/Phone/PhoneHeroMetadata.swift
- iosApp/iosApp/tvOS/Screens/Detail/TVSeriesDetailView.swift
- iosApp/iosApp/tvOS/Screens/Detail/TVSeasonDetailView.swift
- iosApp/iosApp/tvOS/Screens/Detail/TVMovieDetailView.swift
| if protocolV3Available == nil { | ||
| do { | ||
| let capability = try await ContinuumAPI.shared.playbackV3Capability() | ||
| protocolV3Available = capability.enabled | ||
| && capability.protocolVersions.contains(PlaybackProtocolV3.version) | ||
| && capability.features.contains(PlaybackProtocolV3.planFeature) | ||
| } catch let error as HTTPError where error.statusCode == 404 || error.statusCode == 405 { | ||
| protocolV3Available = false | ||
| } | ||
| } | ||
| guard protocolV3Available == true else { return nil } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Capability-probe failures other than 404/405 abort playback instead of falling back to legacy.
The catch only handles 404/405. Any other failure (e.g. a transient .network error, 5xx, timeout) propagates out of startProtocolV3IfAvailable and out of startSession, so the legacy /playback/start path below (Line 361+) is never reached. On a V3-capable server, a transient blip on /playback/capability will hard-fail a playback start that the legacy path could have served. Consider treating unexpected probe failures as "V3 not available for this attempt" (return nil, leaving protocolV3Available unresolved for a later retry) rather than propagating.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@iosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift` around lines 431 -
441, Update the capability-probe error handling in startProtocolV3IfAvailable so
failures other than HTTP 404/405 also return nil and allow startSession to
continue through the legacy /playback/start path. Treat unexpected errors as
unavailable for the current attempt, while leaving protocolV3Available
unresolved so a later retry can probe again.
| videoDecode: videoCodecs.map { codec in | ||
| PlaybackV3VideoDecodeCapability( | ||
| codec: codec, | ||
| decoderName: codec == "mpeg2video" ? "VideoToolbox" : "VideoToolbox", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Redundant ternary — both branches return "VideoToolbox".
codec == "mpeg2video" ? "VideoToolbox" : "VideoToolbox" evaluates to the same value regardless of the condition. Either the intended branch value differs (e.g. mpeg2video reported with a distinct/nil decoder) or this should be simplified to a literal. Please confirm the intent.
🔧 Simplify if no distinct decoder was intended
- decoderName: codec == "mpeg2video" ? "VideoToolbox" : "VideoToolbox",
+ decoderName: "VideoToolbox",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| decoderName: codec == "mpeg2video" ? "VideoToolbox" : "VideoToolbox", | |
| decoderName: "VideoToolbox", |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift` at
line 59, Resolve the redundant ternary in the capabilities construction by
confirming whether mpeg2video needs a distinct decoder value; if not, replace
the codec-dependent expression with the literal "VideoToolbox". Update the
decoderName assignment in the relevant Apple playback capability code while
preserving the intended reported decoder.
d8107f0 to
581252e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8107f0bba
ℹ️ 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".
| return PlaybackExecutionPlan( | ||
| delivery: delivery, | ||
| engine: engine, | ||
| startMode: .absolutePosition(max(0, plan.timeline.playerStartSeconds)), |
There was a problem hiding this comment.
Preserve remux manifest offsets in V3 plans
When a V3 server_remux_hls plan starts from a resume/seek anchor, the session carries the movie-time mapping in timelineOffsetSeconds, but the VM only applies that offset for remuxed AVPlayer HLS when the plan start mode is .startOfManifest. This unconditional .absolutePosition(...) makes the initial V3 remux load drop the offset, so UI time/progress reporting and subsequent seeks start around 0 instead of the resumed source position. Use .startOfManifest for V3 remux-HLS plans, or update the offset calculation to honor V3 remux offsets.
Useful? React with 👍 / 👎.
| sessionId = resolvedSessionId | ||
| currentSession = session |
There was a problem hiding this comment.
Adopt V3 sessions through the common session path
For V3 starts this assigns sessionId/currentSession directly instead of going through adoptSession. When diagnostics capture is enabled, that helper is the only path that records the recent playback session and emits the playback-session breadcrumb, so V3 playback sessions are omitted from manual/crash diagnostics while legacy sessions still appear. Please adopt the synthesized V3 session through the same helper after activeProtocolV3 is set.
Useful? React with 👍 / 👎.
| let protocolV3SubtitleTrackIndex = subtitleTrackIndex.flatMap { | ||
| ApplePlaybackV3PlanAdapter.serverCombinedSubtitleIndex( | ||
| ffmpegStreamIndex: $0, | ||
| in: selectedVersion | ||
| ) | ||
| } |
There was a problem hiding this comment.
Preserve explicit subtitle-off in V3 start requests
When the detail screen passes -1 for “Off”, this mapping feeds it through serverCombinedSubtitleIndex, producing nil, and the request then sends the same nil used for “Auto”. On V3-capable servers that means playback start can still apply saved/default subtitles, or even choose a burned-in subtitle plan, despite the user explicitly selecting Off. Keep the off sentinel distinct from nil/auto when building the V3 start request.
Useful? React with 👍 / 👎.
| retryable: false | ||
| ) | ||
| case .playable(let plan, let resolvedSessionId): | ||
| try ApplePlaybackV3PlanAdapter.validate(plan) |
There was a problem hiding this comment.
Stop allocated V3 sessions when plan validation throws
If the server returns a playable V3 envelope but validate rejects the plan (for example an unsupported runtime correction or client transform), this throw skips the stopPlayback cleanup that the later missing-version path performs. In that invalid-plan scenario playback fails locally while the newly allocated server session remains until idle expiry, consuming a concurrency slot; wrap validation so resolvedSessionId is stopped before rethrowing.
Useful? React with 👍 / 👎.
| hdrDetails: output.hdrDetails, | ||
| subtitles: directSubtitles, | ||
| features: ["apple_native_direct", "apple_local_loopback", "apple_playercore"], | ||
| authHeaderRefresh: true, |
There was a problem hiding this comment.
Don't advertise header refresh until it is implemented
This advertises authHeaderRefresh: true (and the other V3 engines do the same), and the validator accepts plans with headerRefresh == "session", but the client never reads headerRefreshUrl or refreshes stream headers after the initial makeStreamRequest merge. When a V3 server relies on expiring session headers, long HLS/direct playback can keep using stale headers and fail mid-stream; either advertise no refresh support or wire the refresh path before accepting those plans.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2912e3c40f
ℹ️ 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".
| RecentSessionTracker.shared.purge(binding: binding) | ||
| } | ||
| purgeBreadcrumbJournal() | ||
| DiagLog.ring.clear() |
There was a problem hiding this comment.
Preserve crash evidence across the startup auth gate
On tvOS cold launch after an abnormal exit, ContentView first runs its auth-state task while the router is still .loading, which calls activeProfileWillChange() before the authenticated path calls captureLeftoverIfNeeded(). With these new purges, that startup gate deletes the previous run's persisted breadcrumbs and recent playback session IDs before the leftover marker is captured, so the abnormal-exit report is saved without the failed-run evidence it was meant to preserve; only clear this data for an actual server/profile boundary or after the leftover capture has had a chance to read it.
Useful? React with 👍 / 👎.
| let ringSnapshot = DiagLog.ring.snapshot() | ||
| let candidateLines = ringSnapshot.lines + harvestOSLogLines(since: start) | ||
| let lines = Self.logLines(candidateLines, forRunID: runID, since: start) | ||
| let lines = Self.logLines(ringSnapshot.lines, forRunID: runID, since: start) |
There was a problem hiding this comment.
Write an abnormal-exit log sentinel when the ring is empty
For a real tvOS abnormal-exit capture this code runs on the relaunch, but DiagLog.ring is process-local and the runID being filtered is from the crashed process, so this usually produces no lines after OSLog harvesting was removed. Returning nil here leaves no logs.jsonl artifact, and buildBundle later falls back to the current relaunch's live ring instead of freezing an empty failed-run log set; persist the typed logs across runs or at least write an empty logs artifact when no crashed-run lines are available.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 022c072dcd
ℹ️ 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".
| if let binding = currentDiagnosticsBinding { | ||
| RecentSessionTracker.shared.purge(binding: binding) | ||
| } | ||
| purgeBreadcrumbJournal() | ||
| DiagLog.ring.clear() |
There was a problem hiding this comment.
Purge profile-scoped evidence on the actual profile-change path
Putting the new purge only in activeProfileWillChange() misses the normal profile-switch flow: I checked AuthService.profileId and selectProfile, and they call DiagnosticsCoordinator.activeProfileDidChange() without first calling this method. In that common path, the previous profile's recent playback sessions, breadcrumbs, and ring entries remain under the same account binding, so a manual or crash report created after switching profiles can still include evidence from the profile that was just left; move/duplicate the purge onto the profile setter/activeProfileDidChange path before the async eligibility re-check.
Useful? React with 👍 / 👎.
Summary
Testing
Summary by CodeRabbit