Repository navigation
fix(playback): answer HEAD on the v2 HLS playlist - #4459
Conversation
A DLNA renderer (an LG TV) checks the playlist URL with HEAD before it plays it. The v2 playlist route only had GET, so the check got 405 and the TV refused every cast that needed a transcode. The HEAD form runs the same handler and accepts the plan's stream reference like the GET. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t once The HEAD operation now lists silo_rendition and silo_track like the GET. The GET and HEAD playlist handlers are wrapped once when the router is built, so an undeclared media route still fails at startup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Quick104
left a comment
There was a problem hiding this comment.
One finding, outside the lines this PR changes.
Remote playback handoffs get 403 on the new HEAD (low). remotePlaybackRoutes in internal/api/middleware/remote_playback.go matches method and path. It lists GET for the playlist and segments, and HEAD only for original media and subtitles. A device signed in on remote playback handoff credentials can GET /api/v2/playback/transcode/{session_id}/master.m3u8, but a HEAD on the same URL gets 403 before the stream reference is checked. No first-party TV app sends that HEAD today, so nothing breaks yet. The playlist still answers HEAD for a direct login or an st alone, so this gap is easy to miss. The repair is one allowlist entry for HEAD on the playlist; segments stay GET only. The bound-profile check and the handler's own gates still apply. I'm fixing this in a commit on this branch, so there's no need to change it yourself.
Posted by Claude Code (claude-opus-5-5) reviewing for a maintainer.
The handoff route list allowed GET on the playlist but not the HEAD form this branch adds, so a device on handoff credentials got 403 where GET succeeds. Segments stay GET only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Review summaryReviewed head: The change does what it says. I pushed one fix, for a gap outside the lines the PR changed. Addressed
What I checked
Left for the maintainers
Follow-up (not part of this PR)
Validated features: unavailable. The validation board couldn't be read from the review environment, so I couldn't check the PR's User manual: unaffected. The manual doesn't describe DLNA casting or the playlist URL. Other clients: no change needed. Apple, Android, Roku and the web app fetch the playlist with GET. Cross-provider review: one round (Codex, gpt-6.2-sol) on Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green) Fit: the PR fixes a real problem for a third-party casting client with one additive Posted by Claude Code (claude-opus-5-5) reviewing for a maintainer. |
Title: fix(playback): answer HEAD on the v2 HLS playlist
Problem
Related issue: N/A
Validation tasks: none
Other clients: N/A (no client-visible change; Apple, Android, Roku and Web load the playlist with GET)
A DLNA controller that checks a stream URL with HEAD before handing it to a TV can't cast any Silo stream that plays over HLS.
/api/v2/playback/transcode/{session_id}/master.m3u8only registers GET, so the HEAD gets405 Method Not Allowedand the controller gives up before the TV requests anything. Moonfin's DLNA casting hits this: its UPnP library (Platinum) sends the HEAD, so a cast that needs a transcode, such as H.264 with DTS audio to an LG TV, fails at once. The original-file route/api/v2/stream/{session_id}already answers HEAD. This change adds HEAD to the playlist route.Approach
The playlist route gets a HEAD operation,
headPlaybackManifest, that runs the same handler as the GET. Go's HTTP server drops the body for HEAD and keeps the headers the handler sets, includingContent-Length, so the handler doesn't change. Like the GET, the HEAD accepts the plan's signed stream referenceston its own, because a DLNA controller sends noAuthorizationheader. A relayed transcode still asks its node with GET, so nodes and the proxy are unchanged.Stream telemetry now records the playlist route under the request's method, as the original-file route already does, and the HEAD form is in the media route list.
docs/playback-api.mdand the stream reference paragraph indocs/architecture/api-contract.mdlist the HEAD form. The segment route stays GET only. The remote playback handoff route list also allows HEAD on the playlist, so a device on handoff credentials gets the same answer as for GET.Validation
go build ./...;go test ./internal/apiv2/passes;go test -run 'Route|Telemetry|Media' ./internal/api/passes with the media route golden updated.mainit fails with 405; with this change it passes.make lint-changed: 0 issues. OpenAPI, v2 fixtures and web types regenerated and verified.make verify-apiv2-contract: 1 change, none breaking.make verify-route-inventory: current, run in a Linux container (it can't type-check cgo on macOS).Evidence
Requests sent with no
Authorizationheader, only the plan URL'sst, as a DLNA controller sends them. The playback session was started for an H.264 + DTS 5.1 MKV with only HLS offered, so the plan wasserver_remux_hls(hls_audio_adaptation). The playlist grows as segments are written, so lengths differ between runs.Before, upstream
maine0046ab3a:After, this branch on
e0046ab3a:Surface and build: a Docker test server built from each commit. In a cast from Moonfin on iOS to an LG C3, the controller's HEAD (User-Agent
Neptune/1.1.3) now gets 200 and the TV goes on to request the playlist. Playback on that TV still fails, for a client-side reason outside this change: the TV truncates URLs longer than about 1024 characters.Risks
None identified. The change adds an operation to
/api/v2; it doesn't change the GET.Checklist
AI Disclosure
/code-reviewat xhigh on the branch, then again on the fix commit. Fixed: the HEAD operation lacked the playlist'ssilo_renditionandsilo_trackparameters, and wrapping the handler per request had dropped the startup check for undeclared media routes; both handlers are now wrapped once when the router is built. Not changed: a HEAD runs the GET path, so after a restart it can rebuild a lost transcode the following GET would rebuild anyway; a HEAD on a node-relayed session fetches the playlist from the node and discards it; segment routes stay GET only, since no client has been seen sending HEAD there; the Jellyfin-compatible playlist routes are out of scope.🤖 Generated with Claude Code
Note
Add HEAD support for the v2 HLS playback manifest route
/playback/transcode/{session_id}/master.m3u8as operationheadPlaybackManifestin playback_delivery.go, reusing the manifest handler (net/http drops the body for HEAD)methodHandlerswrapper that dispatches HEAD vs GET callbacks, and wires it in router.goheadPlaybackManifestis exempted from the household profile-gate coverage check in household_profile_gate_test.goMacroscope summarized b503f54.