Skip to content

fix(jellycompat): stop offering unreadable files in PlaybackInfo - #2029

Merged
Quick104 merged 1 commit into
Silo-Server:mainfrom
Tobechukwu-Njoku:fix/jellycompat-skip-unreadable-versions
Oct 8, 2026
Merged

Quick104 merged 1 commit into
Silo-Server:mainfrom
Tobechukwu-Njoku:fix/jellycompat-skip-unreadable-versions

Conversation

@Tobechukwu-Njoku

@Tobechukwu-Njoku Tobechukwu-Njoku commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Tobechukwu Njoku

Problem

Closes #1812
Related issue: N/A
Validation tasks: changes #1246 C1

Jellyfin clients were offered files Silo knows it cannot play. For a zero-byte or corrupt file that ffprobe rejected, PlaybackInfo returned one direct-playable source with no container, size or streams. The client tried to play it and failed in its player with no explanation, while the native API refuses the same file as damaged (#1810).

Approach

catalog.FileVersion carries models.MediaFile.ProbeRejected, the rule #1810 added (ffprobe rejected the file and nothing usable is recorded), as Unreadable. The field is not serialized, so neither the v1 nor the v2 view changes. PlaybackInfo leaves unreadable versions out. When nothing the request can use is left, including a MediaSourceId that names an unreadable version, it answers the way Jellyfin does when nothing can play: 200 with an empty MediaSources list, ErrorCode: "NoCompatibleStream" and no play session. Jellyfin Web shows that as a playback error instead of trying to play. Files that have not been probed yet are offered as before.

A request that names the unreadable version gets the error, not a different version, in the same way a route naming a version the item no longer has answers 404 rather than substituting. The existing 400 PlaybackUnavailable answer for sources that do not fit the client's constraints is unchanged.

Validation

  • gofmt, go vet and make lint-changed are clean.
  • New tests cover an item with no readable version, a readable version beside an unreadable one, a request naming the unreadable version in the body and in the route, the same answer with a server bitrate cap in force, an unprobed file that is still offered, and the catalog flag following ProbeRejected. With the new behaviour removed and the fields kept, the six that expect it fail; all pass here.
  • make test-go on this machine fails in internal/jellycompat (TestPlaybackInfoWithoutStripOrToneMapStillHasNoRoute, TestPlaybackInfoSkipsStripWhenRPUCannotBeStripped), internal/apiv2 (TestAdminResourceCapabilitiesAndScope) and internal/playback (hardware transcoding probes). Each of those fails the same way on unchanged main on this machine. A few hardware-probe and internal/transcodenode tests failed in a full run on one tree but not the other; run on their own, they pass or fail identically on both. CI is the reference.
  • Ran the issue's steps on local builds of main and of this branch against the same database: an offline movie library with a zero-byte file, and a movie with a readable 1080p file and a zero-byte 720p file. On main, the zero-byte movie gets one direct-playable source with no size, container or streams, the two-version movie gets both sources, and asking for the 720p file by MediaSourceId returns it. On this branch, the zero-byte movie gets 200, ErrorCode: "NoCompatibleStream", no sources and no PlaySessionId; the two-version movie gets only the 1080p source; and asking for the 720p file gets NoCompatibleStream.

Evidence

Same requests against main and this branch, trimmed to the fields that changed. Every answer is HTTP 200. Paths are cut to the file name and the play session id is replaced.

POST /Items/{Empty One}/PlaybackInfo with {}. The item's only file is zero bytes.

Before (main):

{
  "PlaySessionId": "<id>",
  "MediaSources": [
    {
      "Path": ".../Empty One (2020).mkv",
      "Container": null,
      "Size": null,
      "SupportsDirectPlay": true,
      "SupportsDirectStream": true,
      "MediaStreams": "[0 streams]"
    }
  ]
}

After (this branch):

{
  "ErrorCode": "NoCompatibleStream",
  "MediaSources": []
}

POST /Items/{Two Versions}/PlaybackInfo with {}. The item has a readable 1080p file and a zero-byte 720p file.

Before (main):

{
  "PlaySessionId": "<id>",
  "MediaSources": [
    {
      "Path": ".../Two Versions (2022) - 1080p.mkv",
      "Container": "mkv",
      "Size": 77500,
      "SupportsDirectPlay": true,
      "SupportsDirectStream": true,
      "MediaStreams": "[2 streams]"
    },
    {
      "Path": ".../Two Versions (2022) - 720p.mkv",
      "Container": null,
      "Size": null,
      "SupportsDirectPlay": true,
      "SupportsDirectStream": true,
      "MediaStreams": "[0 streams]"
    }
  ]
}

After (this branch):

{
  "PlaySessionId": "<id>",
  "MediaSources": [
    {
      "Path": ".../Two Versions (2022) - 1080p.mkv",
      "Container": "mkv",
      "Size": 77500,
      "SupportsDirectPlay": true,
      "SupportsDirectStream": true,
      "MediaStreams": "[2 streams]"
    }
  ]
}

The same request with {"MediaSourceId": "<the 720p source>"}.

Before (main):

{
  "PlaySessionId": "<id>",
  "MediaSources": [
    {
      "Path": ".../Two Versions (2022) - 720p.mkv",
      "Container": null,
      "Size": null,
      "SupportsDirectPlay": true,
      "SupportsDirectStream": true,
      "MediaStreams": "[0 streams]"
    }
  ]
}

After (this branch):

{
  "ErrorCode": "NoCompatibleStream",
  "MediaSources": []
}

Surface and build: Jellyfin-compatible API, POST /Items/{id}/PlaybackInfo. Before: main at c762177; after: this branch at a7159a2. Local builds against the same offline test library, with test media only.

Jellyfin Web 12.1, built from the v12.1 tag with silo compat-web install and served by each build, signed in with a test account. "Two Versions" with its zero-byte 720p version selected, then Play:

Before (main) After (this branch)
main: Jellyfin Web shows only its generic Playback Error, There was an error processing the request this branch: Jellyfin Web shows Playback Error, This client isn't compatible with the media and the server isn't sending a compatible media format

On main, PlaybackInfo offers the zero-byte file, no stream request follows, and Jellyfin Web shows only its generic error. On this branch, Jellyfin Web 12.1 also opens that generic dialog on top of the NoCompatibleStream one: after validatePlaybackInfoResult shows the ErrorCode message it rejects, and onPlaybackRejection adds ErrorDefault. It does this for any ErrorCode answer, Jellyfin's own included. So the viewer sees the generic dialog first and the NoCompatibleStream message after closing it:

this branch, as first shown: the generic dialog Jellyfin Web stacks on top of the NoCompatibleStream one

Risks

  • A Jellyfin client that ignores ErrorCode and reads MediaSources[0] gets an empty list where it used to get a source that could not play. Jellyfin itself answers this way, so clients written against Jellyfin already meet this answer.
  • PlaySessionId is now left out when empty. Every answer with sources still sets it.
  • Clients that skip PlaybackInfo still see the unreadable version: Static=true direct play, which Infuse and SenPlayer use, and GET /Items/{id}, which lists it as direct-playable. Covering those is a follow-up.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (Claude desktop app); Claude Code cloud session on claude.ai for the adversarial review
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5 (Ultracode)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: Separate Claude agents in cloud sessions, independent of the one that wrote the change, compared it with independently written fixes and reviewed the diff against the PlaybackInfo handler and its callers. They found two untested paths (the unreadable version named in the route, and a server bitrate cap in force), a doc claim that every client shows the error when only Jellyfin Web is known to, and that Static=true direct play and GET /Items/{id} still offer the file. Two tests were added, the doc and the code comment were corrected, and the remaining gap is listed under Risks.

Note

Omit ffprobe-rejected files from jellycompat PlaybackInfo responses

  • Marks FileVersion values as unreadable when ffprobe rejected the underlying file with no usable stream data, via a new internal Unreadable field in detail.go excluded from JSON output
  • HandlePlaybackInfo in handlers_playback.go skips unreadable versions; if all matching versions are unreadable it returns HTTP 200 with an empty MediaSources list and NoCompatibleStream, without creating a play session
  • Unprobed files and files with retained or newer probe data remain offered; item listing and Static=true direct play are unchanged
  • Documents the new behavior in jellycompat-api.md
  • Behavioral Change: playbackInfoResponseDTO in dto.go omits PlaySessionId when absent and adds an ErrorCode field; requests naming an unreadable MediaSourceId now get NoCompatibleStream instead of a playable sibling version

Macroscope summarized a7159a2.

A zero-byte or corrupt file that ffprobe rejected came back from
PlaybackInfo as one direct-playable source with no container, size or
streams. Jellyfin clients tried to play it and failed in the player,
while the native API refuses the same file as unreadable (Silo-Server#1810).

catalog.FileVersion now carries models.MediaFile.ProbeRejected as an
unserialized Unreadable flag, and PlaybackInfo leaves those versions
out. When nothing the request can use is left, including a
MediaSourceId that names an unreadable version, it answers as Jellyfin
does: 200 with no media sources and ErrorCode NoCompatibleStream, which
clients show to the viewer. Files that were never probed are offered as
before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 7, 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 ❌

@macroscopeapp

macroscopeapp Bot commented Oct 7, 2026

Copy link
Copy Markdown
  • internal/jellycompat/handlers_playback.go: PlaybackInfo now omits unreadable versions, including when a readable version is also available. Add before-and-after PlaybackInfo response excerpts for the same mixed-version item.
  • internal/jellycompat/handlers_playback.go and internal/jellycompat/dto.go: when no readable version is available, PlaybackInfo returns an empty MediaSources list with ErrorCode: "NoCompatibleStream" and no PlaySessionId, which Jellyfin Web renders as a playback error. Add before-and-after response excerpts for the same unreadable-only request and identify the PlaybackInfo/Jellyfin Web surface and the build or commit captured. The PR body currently has no ## Evidence section.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8d5f8f65-87c9-4ac2-9e39-b3c324b9c266
📥 Commits

Reviewing files that changed from the base of the PR and between ed0d3ed and a7159a2.

📒 Files selected for processing (6)
  • docs/jellycompat-api.md
  • internal/catalog/detail.go
  • internal/catalog/detail_unreadable_test.go
  • internal/jellycompat/dto.go
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/playback_info_unreadable_test.go

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


📝 Walkthrough

Walkthrough

Playback negotiation now excludes versions marked unreadable by ffprobe. When no selected readable version remains, the endpoint returns HTTP 200 with an empty MediaSources list and NoCompatibleStream.

Changes

PlaybackInfo unreadable-version handling

Layer / File(s) Summary
Carry probe rejection into playback versions
internal/catalog/detail.go, internal/catalog/detail_unreadable_test.go
FileVersion now carries an internal, JSON-excluded Unreadable flag populated from ProbeRejected(). Tests cover probe-state cases and confirm that JSON omits the flag.
Filter unreadable versions in PlaybackInfo
internal/jellycompat/dto.go, internal/jellycompat/handlers_playback.go, internal/jellycompat/playback_info_unreadable_test.go, docs/jellycompat-api.md
PlaybackInfo skips unreadable versions. If no selected readable version remains, it returns HTTP 200 with an empty MediaSources list and NoCompatibleStream. Tests cover selected IDs, bitrate caps, readable alternatives, and unprobed versions. The API documentation describes the response and its scope.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Catalog as catalog.FileVersion
  participant Handler as HandlePlaybackInfo
  participant DTO as playbackInfoResponseDTO
  participant Client as Jellyfin client
  Catalog->>Handler: FileVersions with Unreadable flags
  Handler->>DTO: Empty MediaSources and NoCompatibleStream
  DTO->>Client: HTTP 200 response
Loading

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to a7159

PlaybackInfo excludes known unreadable versions while retaining unprobed files. No merge-blocking issue is established; proceed with normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #1812 requires PlaybackInfo to omit files known to be unreadable, return a client-visible error when no readable source remains, and keep offering files that have not been probed. The change c…
Out of Scope Changes check ✅ Passed The DTO, catalog, handler, test, and documentation changes support issue #1812's PlaybackInfo behavior. The response-field changes enable the required error response. The reported remaining behavior…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 5 files. (1 skipped: 1…
Title check ✅ Passed The title clearly summarizes the main change: excluding unreadable files from Jellyfin-compatible PlaybackInfo responses.
Description check ✅ Passed The description explains the problem, implementation, response behavior, validation, and remaining scope. It is directly related to the changeset.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Quick104 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Evidence: FAIL

This PR has no Evidence section, and the template's Evidence checklist item was removed too. The change is user-visible under CONTRIBUTING's "Show visible changes": it changes a jellycompat response that clients render (empty MediaSources, new ErrorCode: "NoCompatibleStream", PlaySessionId omitted) and the error state viewers see in Jellyfin clients.

The Validation section already describes the before and after runs in prose. To pass, please add an Evidence section with:

  • Before-and-after PlaybackInfo response excerpts from main and this branch for the same requests, trimmed to the fields that changed: the zero-byte movie, the two-version movie, and the request naming the unreadable 720p MediaSourceId.
  • A Jellyfin Web capture of the new playback error, since the PR says that's what users will see (before: the player failing; after: the error message).
  • The surface and build or commit each capture came from, with hostnames and library details cropped or blurred.

Grok commenting on Quick's behalf.

@Quick104

Quick104 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: a7159a233

Findings: none. I fixed nothing and pushed nothing to this branch.

What I checked:

  • The unreadable check runs after the MediaSourceId filter. A request that names the unreadable version, in the body or in the route, gets NoCompatibleStream. A stale MediaSourceId still falls back as before.
  • Unreadable versions skip DV stripping and never reach the 400 PlaybackUnavailable path for the bitrate cap. The error answer stores no negotiated session.
  • Unreadable is ProbeRejected(), the same rule the native planner uses (internal/playback/plan_v3.go). Files that were never probed, or that have codec or track data from any probe, are still offered.
  • Omitting PlaySessionId matches Jellyfin, which also omits it when nothing can play. The jellyfin-sdk-kotlin and jellyfin-sdk-swift models treat both fields as optional. No production Silo code decodes playbackInfoResponseDTO.
  • The focused internal/jellycompat and internal/catalog tests pass locally on this head. CI is green.

One observation, not a defect: the Jellyfin Kodi add-on reads info["PlaySessionId"] before it checks the sources. On this answer it raises a KeyError instead of showing a message. Real Jellyfin sends the same answer, and before this change Kodi got a source that failed in its player, so it is no worse off.

The docs already name the remaining gaps: GET /Items/{id} still lists the version, and Static=true direct play does not check it.

Evidence: the Evidence section now has before-and-after PlaybackInfo excerpts and the Jellyfin Web surface, and the Evidence check passes. That settles the earlier evidence comment.

Validated features: #1246 C1 (Jellyfin compatibility smoke matrix) is listed as changed and hasn't been run yet, so no passed case regresses. The validator should cover the zero-byte case when they run C1.

User manual: unaffected. No siloserver.org page describes how Jellyfin clients handle damaged files.

Apple/Android parity: not needed. The first-party apps use the native API, which already refuses these files (#1810).

Fit: 9/10 · Readiness: 9/10 — ready

  • Fit: this brings the Jellyfin surface in line with the native API for the same file, at the boundary that already owns source negotiation. It reuses the existing ProbeRejected rule and adds no setting or new public field beyond Jellyfin's own ErrorCode.
  • Readiness: the change is small and covered by tests for each request shape. It matches Jellyfin's own error answer, CI is green, and the evidence is present.

Claude (claude-opus-5-5, Claude Code) reviewing on Quick104's behalf, with a cross-provider pass by Codex (gpt-6.1-sol).

@Quick104
Quick104 merged commit a2bc691 into Silo-Server:main Oct 8, 2026
16 checks passed
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.

[bug] Jellyfin PlaybackInfo offers unreadable files as direct-playable

2 participants