Skip to content

fix(jellycompat): keep a stored subtitle's URL on that subtitle after an earlier one is deleted - #4177

Merged
Quick104 merged 1 commit into
mainfrom
fix/jellycompat-stored-subtitle-identity
Nov 14, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/jellycompat-stored-subtitle-identity

Conversation

@Quick104

@Quick104 Quick104 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

Other clients: N/A (jellycompat-only fix; the Apple, Android, Roku and web clients use the native stream route, whose issued subtitle URLs already carry downloaded_subtitle_id)

Jellyfin apps can get the wrong subtitle after someone deletes a stored (downloaded or uploaded) subtitle. jellycompat numbers stored subtitles after the file's own tracks in list order, and their DeliveryUrl carried only that number. Deleting a stored subtitle moved every later one down by one, so an app that fetched its subtitle URL again (a reload, a seek, a timed window) got the next stored subtitle in another language. The last one in the list got a 404.

On main, with French, German and Spanish stored subtitles, the German subtitle's URL returns the Spanish subtitle once the French one is deleted, and the French URL returns German.

Approach

Each stored subtitle's DeliveryUrl, from PlaybackInfo and from item detail, now also carries StoredSubtitleId. When the subtitle route sees that parameter, it serves that stored subtitle of the media source's file and ignores the index. It answers 404 once the subtitle is deleted, and for an ID that belongs to another file or is malformed. This is how the native stream route already pins its URLs with downloaded_subtitle_id.

The stream indexes Jellyfin apps see don't change. A URL without the parameter, as an app builds from the index itself, still resolves the index against the current list. docs/jellycompat-api.md describes the parameter.

What this leaves alone:

  • A stale index in a new request: Jellyfin Web sends its previous subtitle index when it asks for PlaybackInfo again. After a deletion that index names a different stored subtitle, and Silo then issues a URL pinned to that one. Fixing it needs stable indexes for stored subtitles, which changes the index contract.
  • Apps that build subtitle URLs from the index: Jellyfin for Android TV's external-player path does this, so it keeps the positional behavior.

Validation

  • Handler test: PlaybackInfo issues the URLs, the French stored subtitle is deleted, and the same URLs are fetched again. It fails on main (the German URL returns the Spanish subtitle) and passes with the fix.
  • Live on a dev sandbox, through the Jellyfin API: uploaded French, German and Spanish subtitles to a movie, took the URLs from PlaybackInfo, deleted the French one through DELETE /api/v2/subtitles/stored/{id}, and fetched the same URLs again.
    • On main, the German URL returned the Spanish subtitle and the French URL returned German.
    • With the fix, the German URL returned German and the French URL returned 404.
    • The requests appear in the server's jellycompat request log for each build.
  • go build, gofmt, go mod tidy -diff, go vet, make lint-changed, make lint-router-recovery, make verify-local-paths, verify-bidi, verify-size-ratchet and verify-route-inventory pass.
  • make test-go: jellycompat and every other package pass, apart from the cases below. None of the failing packages imports the changed code.
    • internal/api/handlers, internal/backup, internal/ebookconvert and internal/uploads failed because the build host's umask made their temp directories group-writable. They pass with a private TMPDIR.
    • internal/mediasample and internal/playback each have one real-FFmpeg test that fails the same way on unmodified main on that host.

Evidence: https://evidence.siloserver.org/r/silo-server/jellycompat-stored-subtitle-identity/

Risks

  • Item-detail stored-subtitle URLs used to have no query string and now end in ?StoredSubtitleId=N. An app that adds its token as a second ? query string on these URLs would break. PlaybackInfo URLs already carried ?PlaySessionId=, so such an app would already fail there.
  • The extra parameter is not a credential. Subtitle authorization is unchanged.

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 in T3 Code
  • Tool(s): Claude Code; T3 Code delegated tasks; Codex CLI (plan review)
  • Model(s): claude-opus-5-5 (implementation, code review), gpt-6.1-sol (plan review)
  • Involvement: Fully AI-generated (not yet human verified)
  • Adversarial review:
    • Plan round:

      • gpt-6.1-sol checked the plan against Jellyfin client source. That added the docs change and a 500 for a failed lookup. It also raised the two limitations above, which stay out of scope.
      • claude-opus-5-5 cut a separate 400 for a malformed ID and kept a single serving path.
    • Code review (high): found the following, all fixed:

      • a primary-key lookup with a file check, as the native route does, now replaces a list scan;
      • a redundant parameter;
      • wrong doc wording.

      Other findings predate this change and are left alone: the positional path swallows lookup errors, and a subtitle deleted mid-request returns 500.

    • Simplify: a simplify pass ran on the change.

    • Background review: gpt-6.1-sol reviewed 0f46472 and found nothing to post.

🤖 Generated with Claude Code

… an earlier one is deleted

Stored subtitles take positional stream indexes after the file's own
tracks, and their DeliveryUrl carried only that index. Deleting an
earlier stored subtitle moved every issued URL onto the next one, so a
Jellyfin client refetching its subtitle got another language, or a 404.

Issued stored-subtitle URLs now also carry StoredSubtitleId, and the
subtitle route serves that subtitle of the file whatever the index says,
or 404 once it is gone. URLs without it still resolve by index.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 14, 2026
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

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: e80af200-3b89-4ccb-a678-47a46b09f45f
Commits

Reviewing files that changed from the base of the PR and between 43c8300 and 0f46472.

Files selected for processing: 5

  • docs/jellycompat-api.md
  • internal/jellycompat/handlers_items.go
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/playback_subtitle_auth_test.go
  • internal/jellycompat/streams.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T20:41:13.980304Z 0f46472 PR opened
🔒 Security Review ✅ Completed 2026-11-14T20:43:11.206464Z 0f46472 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-kody

silo-kody Bot commented Nov 14, 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 bug Something isn't working go Pull requests that update go code impact: playback Can't play, stalls, or wrong media priority: P2 Limited scope, workaround exists, or polish triaged High-confidence review completed; does not mean fixed, validated, or accepted for release. labels Nov 14, 2026
@Quick104
Quick104 merged commit e5b5e51 into main Nov 14, 2026
18 checks passed
@Quick104
Quick104 deleted the fix/jellycompat-stored-subtitle-identity branch November 14, 2026 21:11
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 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. triaged High-confidence review completed; does not mean fixed, validated, or accepted for release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant