Skip to content

fix(playback): answer HEAD on the v2 HLS playlist - #4459

Merged
Quick104 merged 3 commits into
Silo-Server:mainfrom
Brady3035:fix-hls-playlist-head
Nov 18, 2026
Merged

Quick104 merged 3 commits into
Silo-Server:mainfrom
Brady3035:fix-hls-playlist-head

Conversation

@Brady3035

@Brady3035 Brady3035 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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.m3u8 only registers GET, so the HEAD gets 405 Method Not Allowed and 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, including Content-Length, so the handler doesn't change. Like the GET, the HEAD accepts the plan's signed stream reference st on its own, because a DLNA controller sends no Authorization header. 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.md and the stream reference paragraph in docs/architecture/api-contract.md list 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: go build ./...; go test ./internal/apiv2/ passes; go test -run 'Route|Telemetry|Media' ./internal/api/ passes with the media route golden updated.
  • The stream reference test gets a row for HEAD on the playlist. On upstream main it 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).
  • Not run: the full Go suite, the web suite and the database jobs.

Evidence

Requests sent with no Authorization header, only the plan URL's st, 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 was server_remux_hls (hls_audio_adaptation). The playlist grows as segments are written, so lengths differ between runs.

Before, upstream main e0046ab3a:

HEAD /api/v2/playback/transcode/{session_id}/master.m3u8 -> 405 content-type=application/problem+json allow=GET
GET  /api/v2/playback/transcode/{session_id}/master.m3u8 -> 200 content-type=application/vnd.apple.mpegurl

After, this branch on e0046ab3a:

HEAD /api/v2/playback/transcode/{session_id}/master.m3u8 -> 200 content-type=application/vnd.apple.mpegurl content-length=3333
GET  /api/v2/playback/transcode/{session_id}/master.m3u8 -> 200 content-type=application/vnd.apple.mpegurl

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

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: AI-assisted
  • Adversarial review: Claude Code /code-review at xhigh on the branch, then again on the fix commit. Fixed: the HEAD operation lacked the playlist's silo_rendition and silo_track parameters, 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

  • Registers HEAD /playback/transcode/{session_id}/master.m3u8 as operation headPlaybackManifest in playback_delivery.go, reusing the manifest handler (net/http drops the body for HEAD)
  • Adds the route to the native media route inventory in media_routes.go via a methodHandlers wrapper that dispatches HEAD vs GET callbacks, and wires it in router.go
  • Accepts the signed stream reference for HEAD manifest requests in playback_stream_reference.go, and permits them for remote-playback handoff sessions in remote_playback.go
  • Updates the OpenAPI contract, generated web operation map/schema, docs tables, and test fixtures for the new operation
  • Behavioral Change: the media route inventory and OpenAPI contract now expose a new HEAD route; headPlaybackManifest is exempted from the household profile-gate coverage check in household_profile_gate_test.go

Macroscope summarized b503f54.

Brady3035 and others added 2 commits November 17, 2026 17:01
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

silo-kody Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 17, 2026
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The playback transcode master manifest now accepts HEAD requests. The change adds routing, stream-reference handling, API schemas, and documentation for the method.

Changes: Playback manifest HEAD

Layer / File(s) Summary
HTTP HEAD route and dispatch
internal/api/media_routes.go, internal/api/router.go, internal/api/handlers/playback.go, internal/api/testdata/media_routes.txt, internal/api/middleware/remote_playback.go
The media routes include HEAD for the transcode master manifest. The router handles GET and HEAD through the manifest handler, while segment handling remains GET-only. Route fixtures and remote playback routes include HEAD.
V2 manifest delivery and stream references
internal/apiv2/playback_delivery.go, internal/apiv2/playback_stream_reference.go, internal/apiv2/playback_stream_reference_test.go, internal/apiv2/household_profile_gate_test.go
The v2 delivery routes register HEAD and apply manifest query parameters to it. The stream-reference operation set and its route test include HEAD. The household profile-gate exemptions include headPlaybackManifest.
API schemas and documentation
contracts/api/v2/openapi.json, web/src/api/v2/schema.ts, web/src/api/v2/operations.ts, docs/playback-api.md, docs/architecture/api-contract.md
The OpenAPI and web API schemas describe the HEAD operation, its parameters, and responses. The playback API documentation lists HEAD alongside GET.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Possibly related issues

  • Silo-Server/silo-server#4029 — This change adds HEAD support for signed stream references on the playlist route. The issue’s GET authorization and CORS concerns remain outside this change.

Possibly related PRs

Suggested reviewers: blurbery, quick104

Merge Risk: Minimal · up to b503f

This change lets DLNA controllers send HEAD requests for the playback playlist instead of receiving 405. It also keeps remote handoff sessions working for that request, and GET behavior is unchanged. No merge-blocking risk was found.

Security architecture risk: Minimal · up to b503f

The new HEAD method uses the playlist’s existing access and ownership controls. No introduced security, failure-containment, or recovery-boundary regression was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed externally reachable authority is another HTTP method for an existing manifest resource. A caller still needs an accepted account credential or a valid session-bound stream reference. Comparison with GET established no additional account, profile, media-resource, administrative, or node-selection authority from this PR.

Trust Boundaries and Controls

  • observed — The new remote-playback allowlist entry is anchored to HEAD on master.m3u8. Matching still requires an exact method and an already-clean path. Access-token admission rejects conflicting profile headers and narrows handoff claims to the bound profile and user role. Current-credential revalidation also consumes this allowlist, retaining its active-session and bound-profile checks.

Resilience and Maintainability Implications

  • observed — HEAD inherits existing recovery controls rather than introducing another transition implementation. Local reconstruction uses per-session single-flight and lifecycle locking, conditionally confirms recovered execution, and invokes rollback for a failed provisional rebuild. Rehome is single-flighted per process and bounded independently of an individual caller’s cancellation. Remote replacement checks denial and expected route before publication, and losing or failed starts have reservation and transport cleanup paths. These controls are unchanged from the PR base; distributed coordination and every downstream cleanup implementation were not fully verified.
Pre-merge checks: Passed 2

Check name Status Explanation
Title check Passed The title names the primary change: adding HEAD handling to the v2 HLS playlist route. It follows the conventional-commit style and matches the changeset, which adds a HEAD operation for /api/v2/playb…
Description check Passed The description states the problem (DLNA controllers receive 405 on HEAD to the playlist route), the approach (HEAD operation reusing the GET handler, stream reference acceptance, remote-playback allo…
Full details: Title check

Explanation

The title names the primary change: adding HEAD handling to the v2 HLS playlist route. It follows the conventional-commit style and matches the changeset, which adds a HEAD operation for /api/v2/playback/transcode/{session_id}/master.m3u8.

Full details: Description check

Explanation

The description states the problem (DLNA controllers receive 405 on HEAD to the playlist route), the approach (HEAD operation reusing the GET handler, stream reference acceptance, remote-playback allowance), validation steps, and evidence. This matches the changeset files, including the OpenAPI contract, router, media routes, stream reference, remote playback, and docs.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cc5fa9e7-07ed-4dbd-ad93-8aecb2b2f94e
Commits

Reviewing files that changed from the base of the PR and between 83b40ad and 7075fd0.

Files selected for processing: 13

  • contracts/api/v2/openapi.json
  • docs/architecture/api-contract.md
  • docs/playback-api.md
  • internal/api/handlers/playback.go
  • internal/api/media_routes.go
  • internal/api/router.go
  • internal/api/testdata/media_routes.txt
  • internal/apiv2/household_profile_gate_test.go
  • internal/apiv2/playback_delivery.go
  • internal/apiv2/playback_stream_reference.go
  • internal/apiv2/playback_stream_reference_test.go
  • web/src/api/v2/operations.ts
  • web/src/api/v2/schema.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@silo-triage silo-triage Bot added bug Something isn't working impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish labels Nov 17, 2026

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

silo-kody Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 4 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility

@Quick104

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: b503f54a081bc5939465ce36191330498b4f8a37

The change does what it says. I pushed one fix, for a gap outside the lines the PR changed.

Addressed

  • Remote playback handoffs got 403 on the new HEAD: the handoff route list allowed GET on the playlist but not HEAD. b503f54a0 adds HEAD for the playlist only; segments stay GET only. A check of remotePlaybackAllowsRoute failed on 7075fd0ac and passes with the fix, and go test ./internal/api/middleware/ passes.

What I checked

  • The new row in TestPlaybackDeliveryAcceptsStreamReferenceAlone fails on the base (e0046ab3a) with the reported 405 method_not_allowed for HEAD …/master.m3u8 and passes on this branch. go test ./internal/apiv2/ and the route, telemetry and manifest tests in ./internal/api/ pass.
  • A HEAD gets the same gate chain as the GET. headPlaybackManifest is in streamReferenceOperations, so st alone authorizes it, and the profile and egress checks inside the handler run unchanged.
  • Response headers on HEAD match the GET on every path. The local playlist sets Content-Length itself. On a relayed session the relay still asks the node with GET, then sends the rewritten length, or the node's own when there is no st. An ended or missing session answers HEAD with the same 410 or 404 as the GET.
  • Telemetry doesn't count a HEAD body, and the segment acknowledgement still runs only on GET. methodHandlers wraps each handler once when the router is built, so the startup check for undeclared media routes covers both methods.
  • The OpenAPI HEAD operation lists the same parameters as the GET. Its security and error responses follow the existing media and subtitle HEAD operations. Like them, it lists bearer auth even though st alone also works. That is a contract-wide convention, not something this PR introduced.

Left for the maintainers

  • A HEAD runs everything the GET runs. After a restart or a node failure, a probe alone can rebuild the transcode or move it to another node. Each probe also refreshes the session's idle clock, on the API and, through the relayed GET, on the node. The PR description already names this. The GET that follows does the same work, so it costs something only when a controller probes and never fetches, or keeps probing a stopped stream. Excluding HEAD from activity refresh would also mean telling the node that a relayed request was a probe. I don't think that's worth adding without evidence that controllers re-probe.

Follow-up (not part of this PR)

  • The Jellyfin-compatible playlist routes (/Videos/{id}/master.m3u8 and its siblings) still accept only GET, though Jellyfin itself answers HEAD on its master playlists. That gap predates this PR, and I've started a separate fix for it.

Validated features: unavailable. The validation board couldn't be read from the review environment, so I couldn't check the PR's Validation tasks: none line against passed cases. The change adds an operation and leaves the GET path's behavior unchanged.

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 7075fd0ac. It found the handoff gap fixed above and the Jellyfin-compatible gap now in a separate fix. It also raised the probe side effects above and the OpenAPI security note; both are covered above.

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 /api/v2 operation. It follows the pattern the media and subtitle routes already use. Readiness: a test that failed on the base shows the fix, and the author's before-and-after requests show it working against a real controller.

Posted by Claude Code (claude-opus-5-5) reviewing for a maintainer.

@Quick104
Quick104 merged commit 951a018 into Silo-Server:main Nov 18, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants