Skip to content

fix(segments): read from the core endpoint so segments load again - #225

Merged
rlauuzo merged 1 commit into
masterfrom
fix/segment-read-core-endpoint
Aug 19, 2026
Merged

fix(segments): read from the core endpoint so segments load again#225
rlauuzo merged 1 commit into
masterfrom
fix/segment-read-core-endpoint

Conversation

@rlauuzo

@rlauuzo rlauuzo commented Aug 19, 2026

Copy link
Copy Markdown
Member

The editor loads no segments at all. It renders "Something went wrong" and DevTools shows the list query failing with 405 on GET /MediaSegmentsApi/{itemId}. Reported in intro-skipper/segment-editor-plugin#17 against Jellyfin 10.11.11 with Intro Skipper 1.10.11.22.

Commit 3a3de4e moved the read to that route to escape the playback filtering that hides premiere intros. No released plugin serves a GET there. SegmentEditorController registers the route for POST and DELETE only, so the path matches but the verb does not and ASP.NET answers 405. Writes were unaffected, which is why saving still worked.

What this does

Reads Jellyfin's core /MediaSegments/{itemId} again. That response is still shaped for playback, so premiere intros stay hidden until the unfiltered read arrives as Phase 1 of docs/plans/plugin-api-integration.md, behind the Phase 0 capability probe.

I did not add a probe-and-fallback, because it would have failed twice over. The editor read implemented on the plugin's expand-segment-editor-workflows branch returns a bare array, not the core { Items } envelope. Parsing it as { Items } yields zero segments, caches itself as working, and hands batchSaveSegments an empty delete baseline, so every save recreates the segments as duplicates with no error shown.

tools/server.mjs now answers 405 on that route like every released plugin. It had been serving the editor GET, which is why local runs stayed green while every user was broken. Phase 0 adds the MOCK_EDITOR_API switch that lets the mock serve the real editor shape.

Tests

The previous test asserted the URL the code itself built, so it agreed with the code no matter which endpoint it pointed at. Replaced with four cases: the core endpoint and auth header, a two-segment payload asserting order and tick conversion on both elements, an absent Items array, and a 500 that propagates rather than reporting an empty list.

704 tests across 84 files pass. tsc --noEmit, oxlint and oxfmt --check are clean.

Fixes intro-skipper/segment-editor-plugin#17

Summary by Sourcery

Restore editor segment reads by using the supported Jellyfin core endpoint and align the mock server and tests with production behavior.

Bug Fixes:

  • Restore segment loading by reading item segments from Jellyfin’s core endpoint while retaining plugin-backed writes.
  • Return a method-not-allowed response from the mock plugin read route to match released plugin behavior.

Enhancements:

  • Expand segment-read coverage for endpoint selection, authentication, multi-segment conversion, malformed successful responses, and failed requests.

Tests:

  • Replace endpoint-coupled tests with coverage that verifies the core read endpoint, ordering, tick conversion, empty responses, and error propagation.

Commit 3a3de4e pointed the segment read at Intro-Skipper's
MediaSegmentsApi/{itemId} to escape the playback filtering that hides
premiere intros. No released plugin serves a GET on that route. It is
registered for POST and DELETE only, so ASP.NET answers 405 and the
editor rendered "Something went wrong" instead of any segments.

Read Jellyfin's core /MediaSegments/{itemId} again. That response is
still shaped for playback, so premiere intros stay hidden until the
unfiltered read lands as Phase 1 of docs/plans/plugin-api-integration.md,
behind the Phase 0 capability probe.

Probing the editor route first and falling back would have failed twice
over. The implementation on the plugin's expand-segment-editor-workflows
branch returns a bare array rather than the core { Items } envelope, so
it parses as zero segments and hands batchSaveSegments an empty delete
baseline, which recreates every segment as a duplicate.

The mock server had served the editor GET, which is why local runs
stayed green through the breakage. It now answers 405 like every
released plugin.

Fixes intro-skipper/segment-editor-plugin#17
@sourcery-ai

sourcery-ai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Reviewer's Guide

Restore segment reading to Jellyfin’s core /MediaSegments endpoint, harden segment parsing and error handling, and align the mock server and tests so the editor behavior matches real plugins (writes via MediaSegmentsApi, reads via core).

File-Level Changes

Change Details Files
Segment reads are pointed back to Jellyfin’s core /MediaSegments/{itemId} endpoint while keeping writes on the plugin’s MediaSegmentsApi routes.
  • Introduced a dedicated core segment endpoint builder separate from the plugin write endpoint builder.
  • Updated getSegmentsById to call the core endpoint for reads and documented the interaction with playback filtering and future unfiltered editor API.
  • Maintained write operations on MediaSegmentsApi while constraining reads to the core endpoint.
src/services/segments/api.ts
Segment read tests now pin the core endpoint behavior, tick conversion, empty responses, and error propagation.
  • Refactored tests to assert the exact core URL and auth header used by getSegmentsById.
  • Added fixtures for intro and outro segment payloads and a helper to build realistic Jellyfin JSON responses.
  • Extended coverage with cases for multi-segment ordering and tick-to-seconds conversion, handling missing Items, and surfacing non-200 errors instead of returning empty lists.
src/__tests__/segment-read-endpoint.test.ts
The local mock server’s segment editor API now matches real plugin behavior by rejecting GETs to MediaSegmentsApi and documenting the phase-based editor API plan.
  • Changed the MediaSegmentsApi mock route to return a 405 Method Not Allowed for GET, keeping POST and DELETE as write operations.
  • Added commentary explaining why serving GET locally masked the production failure and how the future editor API will return a bare array payload.
  • Ensured the mock server no longer enables unsupported read paths that could let tests pass while real deployments fail.
tools/server.mjs

Assessment against linked issues

Issue Objective Addressed Explanation
intro-skipper/segment-editor-plugin#17 Modify the Segment Editor segment-read logic so that segments successfully load (no 405) when used with existing Intro Skipper versions that do not implement GET /MediaSegmentsApi/{itemId}.
intro-skipper/segment-editor-plugin#17 Ensure the segment read path correctly handles the core /MediaSegments/{itemId} response shape, including proper segment ordering, tick conversion, empty results, and error propagation.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit efe0b77.

@capy-ai capy-ai Bot 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.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy Review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rlauuzo
rlauuzo merged commit 8aecd83 into master Aug 19, 2026
6 checks passed
@rlauuzo
rlauuzo deleted the fix/segment-read-core-endpoint branch August 19, 2026 18:19
@kilo-code-bot

kilo-code-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • src/__tests__/segment-read-endpoint.test.ts
  • src/services/segments/api.ts
  • tools/server.mjs

Reviewed by free · Input: 64.3K · Output: 22.7K · Cached: 627.1K

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.

Segment Editor fails to load segments - 405 (Method Not Allowed) on GET /MediaSegmentsApi/{itemId}

1 participant