Skip to content

fix(jellycompat): accept an empty stream index in playback requests - #2970

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/1246-empty-stream-index
Oct 23, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/1246-empty-stream-index

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #1246
Validation tasks: unblocks #1246 C1

Pressing Play on a series page in Jellyfin Web 12.1 shows "Playback Error" instead of starting the episode. Jellyfin Web sends "SubtitleStreamIndex": "" in that PlaybackInfo request. Jellyfin reads an empty string as an unset number, but Silo rejects the whole request with 400 Invalid playback request. Playing a movie, or an episode from its own page, works because those requests send a number.

This change reads an empty or blank AudioStreamIndex or SubtitleStreamIndex as unset, the same as null or leaving the field out. Silo then picks the tracks it would pick for a request without them.

Approach

compatIntValue already accepted a number or a numeric string. It is now a nullable value, so an empty string decodes as "not set" instead of as stream 0. A pointer field can't express that: encoding/json allocates the pointer before the decoder runs, so the field would have read as index 0. PlaybackInfo and the /Sessions/Playing* progress reports share this type, so both accept the empty string. A value that is neither a number nor blank still returns 400.

The audio-change handling in progress reports moved unchanged into its own method, because the linter flags its nesting once the condition line changes.

Jellyfin's JsonNullableStructConverter does the same for every nullable number ("Required - some clients send an empty string"). This change covers only the two stream indexes, the fields seen arriving empty.

docs/jellycompat-api.md now states that an empty or blank index counts as an omitted field, and that 0 is stream 0.

Validation

  • Go gate from CONTRIBUTING.md: build, gofmt, go vet, make lint-changed, make lint-router-recovery and the verify-* targets pass. Web steps not run; no web files changed.
  • make test-go passes except TestPlaybackInfoWithoutStripOrToneMapStillHasNoRoute and TestPlaybackInfoSkipsStripWhenRPUCannotBeStripped, which fail the same way on unchanged main on this machine (local FFmpeg build).
  • The request-decoding test now covers empty, blank and null indexes, plus an explicit 0. Its empty-string case fails without the fix.
  • Manual: Jellyfin Web 12.1 in Google Chrome against a local build with synthetic media. Play from a series page now starts the first episode, at desktop and phone widths. Jellyfin Web's progress, start and stop reports returned 204. Findroid 1.1.0 and Jellyfin for Android TV 0.19.10 also got 204 for all of theirs, on a build of this change from before the lint-only refactor.

Evidence

Jellyfin Web 12.1, the same series and profile, 10 seconds after pressing Play on the series page.

Evidence: https://evidence.siloserver.org/r/silo-server/pr-2970/

Surface and build: Jellyfin Web 12.1 (installed by Silo), Google Chrome, desktop and phone width. Before is main; after is main with this change and #2934. In Chrome, direct play also needs #2934 (#2879). Without it, the episode now starts loading but stays on the spinner.

Risks

None identified. A request that sent an empty index used to fail. It now behaves like a request without the field.

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 says there is none.

AI Disclosure

  • Harness: Claude Code (via T3 Code); Codex CLI for code review
  • Tool(s): Claude Code, Codex CLI, GitHub CLI, Playwright, agent-device
  • Model(s): claude-opus-5-5; gpt-6.1-sol (code review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: two independent reviews of the branch diff (claude-opus-5-5 and gpt-6.1-sol) covering correctness, repository standards and the reported failure, run twice. Round one found only a readability point in the new test, which was taken. Round two, after the test rewrite and the lint-driven changes, found nothing.

Note

Accept empty stream index in jellycompat playback and session-report requests

Replaces nullable pointer fields for audio and subtitle stream indexes with a value-based compatIntValue wrapper that carries its own set flag, so an explicit zero stays distinct from an omitted value. The decoder in handlers_playback.go now accepts numbers, numeric strings, and treats null, empty, and blank strings as unset for both playback-info and session-report requests.

  • Audio and subtitle selection in HandlePlaybackInfo and buildPlaybackSource only applies a requested index when the wrapper reports the request set one and the index is valid
  • Extracts the reported-audio-selection block from handlePlaybackReport into a new applyReportedAudioSelection helper
  • Updates tests to table-driven coverage for numeric strings, explicit zero, null, empty, and blank values, and documents the behavior in jellycompat-api.md
  • Behavioral Change: clients that previously sent an empty or blank string for a stream index are now treated as omitted instead of a decode failure; explicit 0 now selects stream zero

Macroscope summarized 90ccda4.

…uests

Jellyfin Web 12.1 sends "SubtitleStreamIndex":"" in PlaybackInfo when
Play starts from a series page. Jellyfin reads an empty string as an unset
nullable number; Silo rejected the request with 400, so the episode never
started. Session progress reports share the same decoder.
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Oct 23, 2026
@silo-kody

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

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ 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: 23f56b97-3ab5-469e-870a-d826d07e8bd3
📥 Commits

Reviewing files that changed from the base of the PR and between 31fabc7 and bb4c9f1.

📒 Files selected for processing: 5
  • internal/jellycompat/audio_profile_streams_test.go
  • internal/jellycompat/audio_selection_test.go
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/moonfin_profile_test.go
  • internal/jellycompat/streams.go

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

📝 Walkthrough

Playback request and report stream indexes now use value-based representations with explicit set state. Request decoding accepts numeric values and numeric strings, while null and blank values remain unset. Audio selection from playback reports uses a dedicated helper.

Changes: Stream index compatibility

Layer / File(s) Summary
Decode and apply request indexes
internal/jellycompat/handlers_playback.go, internal/jellycompat/audio_selection_test.go, internal/jellycompat/audio_profile_streams_test.go, internal/jellycompat/moonfin_profile_test.go
Request audio and subtitle indexes use a value-plus-set representation. Numeric values and numeric strings are set; null and blank strings are unset. Query overrides and stream selection use the new representation. Tests cover decoding values and unset cases.
Apply reported audio selections
internal/jellycompat/streams.go
Playback reports use value-typed audio and subtitle indexes. Changed audio selections are handled by a helper that updates the play session and logs failures or resolved track details.

Priority: ➖ Normal

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

Change: Bug fix

Suggested labels: bug, go, size/M

Suggested reviewers: quick104, neurekadev

Merge Risk: ⚪ Minimal · up to bb4c9

No merge-blocking issue was established for the stream-index compatibility change. It is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the primary change: accepting empty stream indexes in jellycompat playback requests.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description clearly explains the empty and blank stream-index issue, the decoder and selection changes, affected request types, tests, validation, and user-visible behavior. It direct…
Full details: Description check

Explanation

The pull request description clearly explains the empty and blank stream-index issue, the decoder and selection changes, affected request types, tests, validation, and user-visible behavior. It directly matches the changeset.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · 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.

@macroscopeapp

macroscopeapp Bot commented Oct 23, 2026

Copy link
Copy Markdown
  • internal/jellycompat/handlers_playback.go (using the shared parsing in internal/jellycompat/streams.go): Jellyfin Web playback from a series page now starts when SubtitleStreamIndex is blank instead of showing Playback Error. The Evidence table is empty; add before-and-after captures of the same flow and a short recording of pressing Play through playback start, with the surface and build or commit identified.

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

Posted via Macroscope — Visible change evidence

@macroscopeapp

macroscopeapp Bot commented Oct 23, 2026

Copy link
Copy Markdown

Please change the line to Validation tasks: changes #1246 C1. The task currently records C1 as Not run, so there is no recorded result to call unblocked. This diff does reach the Jellyfin playback flow covered by C1. The Chrome direct-play scenario cited in the PR also depends on #2934, which remains open; avoid implying this PR alone makes that end-to-end run ready.

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@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, low severity: the contract doc doesn't describe the new input rule.

docs/jellycompat-api.md (around line 116) tells clients they "must omit SubtitleStreamIndex" to get a fresh automatic subtitle selection. After this change, null, an empty string, or a blank string for SubtitleStreamIndex or AudioStreamIndex gives the same result as leaving the field out, in PlaybackInfo and in /Sessions/Playing* reports, and an explicit 0 or -1 still counts as a choice. A client author who reads the doc today can't tell that "" is accepted, or that it means "unset" and not stream 0. The repository's rules ask for the docs/*-api.md file to change along with the contract. The fix is one sentence in that paragraph.

I'm fixing this in a commit on this branch, so there's no need to change it yourself.

No other findings. The code review covered line-by-line behavior, removed guards, callers, contract and failure handling, plus a separate cross-provider pass. An empty index never reaches stream 0 or Off, an explicit 0 stays distinct from unset, the moved audio-selection code behaves exactly as before, and nothing marshals or stores these request types.

@silo-kody

silo-kody Bot commented Oct 23, 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 ❌
⚠️ 1 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

@Quick104

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: bb4c9f1. Branch head after my commit: 90ccda4.

Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)

Fit: this fixes a real Jellyfin Web 12.1 failure, where pressing Play on a series page shows "Playback Error". It brings Silo in line with how Jellyfin reads an empty nullable number, it changes only the type that both affected request bodies already share, and it adds no new surface.

Readiness: an empty or blank index now means "unset" everywhere it is read, and never stream 0 or Off. That holds for PlaybackInfo subtitle and audio selection, buildPlaybackSource, query overrides, and /Sessions/Playing* audio switching. An explicit 0 or -1 is still a choice. The audio-selection block that moved into applyReportedAudioSelection behaves exactly as before. Nothing marshals or stores these request types, so the struct change can't reach the wire or another node. A scratch test that decodes {"SubtitleStreamIndex":""} and {"AudioStreamIndex":" "} into both request types fails on the base with strconv.Atoi: parsing "" and passes on this branch. The PR's own table test can't be run on the base because it calls the new get() accessor.

Addressed

  • The contract doc didn't describe the new input rule. 90ccda4 adds a sentence to docs/jellycompat-api.md: null, an empty string, or a blank string for either index counts as leaving the field out, and 0 is stream 0.

Left for maintainers: nothing.

Other feedback

Validated features: no case recorded as passed is affected. Validation tasks: unblocks #1246 C1 is correct.

Related PRs: this PR and #2934 touch different hunks of handlers_playback.go and merge cleanly in either order. The focused tests pass with both applied. Chrome direct play from a series page needs both.

User manual: no change needed. The fix restores expected Jellyfin Web behavior and doesn't change any documented setting or step.

Apple/Android: not affected. This is jellycompat input parsing only; the native clients use /api/v2.

Review method: three finders (diff and callers; contract and failure; cleanup and conventions), a validation check, and a cross-provider round (gpt-6.1-sol). None found a correctness defect.

@Quick104
Quick104 merged commit 5c8a39d into Silo-Server:main Oct 23, 2026
16 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 go Pull requests that update go code size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants