Skip to content

fix(metadata): read local artwork in title folders linked out of the library - #2558

Merged
Quick104 merged 12 commits into
Silo-Server:mainfrom
blurbery:fix/local-artwork-symlinked-title-folders
Nov 2, 2026
Merged

Quick104 merged 12 commits into
Silo-Server:mainfrom
blurbery:fix/local-artwork-symlinked-title-folders

Conversation

@blurbery

@blurbery blurbery commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2552
Related issue: N/A
Validation tasks: reaches #1143 C5; #1144 C2; Silo-Server/silo-apple#307 C2; Silo-Server/silo-apple#308 C2; Silo-Server/silo-android#317 C2; Silo-Server/silo-android#318 C2; #1136 C1; Silo-Server/silo-apple#303 C1; Silo-Server/silo-apple#304 C1; Silo-Server/silo-android#314 C1; Silo-Server/silo-android#313 C1 (all Passed), only for libraries whose title folders are symlinks out of the library. There, a person's local photo from a title's .actors folder, and title, season and episode artwork shown on person pages and calendar cards, now appear where they were refused before. That still meets each case's criterion (a person with a photo shows it; releases and dates are unchanged). Libraries without linked title folders take the same path as before, so a re-check is only needed if the fixture library uses that layout.

Libraries whose title folders are symlinks into another directory tree get none of their local artwork. Download managers and debrid or cloud mounts commonly lay libraries out this way: one link per title in the library folder, pointing to where the files really live. Silo scans and plays the videos through those links, but every poster, backdrop, season and episode image beside them is refused as local image path outside library roots, and the job waits 7 days before trying again. On my server that is about 8,700 local artwork jobs. #2552 has the details.

The refusal is deliberate protection against a symlink planted inside a library that leads out of it. This change keeps that protection and makes one exception: an image is read when the folder it sits in also holds a file the scanner catalogued for the same title.

Approach

When the symlink-resolving check finds that an image's folders lead out of every library root, the processor now walks from the image's folder up to, but not including, the library root. It accepts the image at the first folder that meets all of these:

  • the folder physically contains the image: its resolved path contains the image's resolved folder, so a folder above the link that leads out can't vouch for it;
  • media_files has a present file of the same title under the folder's logical path (CatalogedFilesUnder, keyed by content ID; an episode's file carries its series' ID, so season and episode images use the series);
  • with the folder opened as an os.Root, that catalogued file is the same file through the root as at its catalogued path (fspath.SameFile). os.Root won't follow a link out of the folder, so a catalogued file that is itself a link elsewhere proves nothing.

The image is then read through that root with the existing leaf checks: no symlinked leaf, a regular file, the size cap, and os.SameFile between the Lstat and the opened handle. Anything that fails keeps today's outside-roots refusal and its 7-day park. Every cataloged file of the title under the folder is tried, 32 at a time in path order, before the image is refused. A storage error while checking, such as a mount that stops answering, or a failed listing retries on the normal schedule as local image read failed instead of parking. Paths inside the opened folder come from resolved paths, as in readConfinedLocalImage, so a link inside the title folder that stays in it, absolute or not, doesn't stop the read. The paths arrive fspath-encoded, as the catalog stores them, and each check decodes them at the file system (fspath.EvalSymlinks, Stat, Lstat and Readlink), so a title folder whose name isn't UTF-8 works too.

Person photos from a title's .actors folder go through the same check, vouched for by the crediting title's files, so they now appear for these libraries too.

This is the trust #644 settled on for transcode inputs: the catalogued media_files path is the authorization boundary. Someone who can retarget a catalogued symlink can already change which video Silo plays and transcodes, so reading the artwork beside it adds no new trust.

The admin image picker reads local sidecars through the same helper, both to preview them and to apply the one an admin picks, so admins can choose these images too.

I added the rule to docs/architecture/local-nfo-metadata.md, where the confinement is described. A migration (20261102003211_requeue_local_artwork_refused_outside_roots.sql) queues the file:// jobs refused before with the outside-roots text again, because a job that spent its attempts on that refusal is parked until its source path changes.

This is server-only. There is no API change; titles in these libraries just get their local artwork. Nothing changes for jellycompat or the native clients beyond the artwork they now receive.

Validation

  • Regression tests (no database), using real symlinks in temporary folders:

    • a symlinked title folder with a catalogued video caches its poster, and a backdrop in a subfolder of it;
    • a symlinked series folder is vouched for by an episode in a season folder below it;
    • the same layout without a catalogued file, or with a root resolver that can't list files, is refused with the stable outside-roots text;
    • a symlink planted inside a real title folder is refused even though the title has a catalogued file in that folder;
    • a catalogued file that is itself a link out of the title folder doesn't vouch for it;
    • fanart reached through an absolute link that stays inside the title folder is read, and a cataloged video that is an absolute or relative link to another file in the folder still vouches for it, while a link loop ends the check;
    • a linked title folder whose name needs fspath encoding is vouched for by its catalogued video (TestProcessLocalImageAcceptsSymlinkedTitleFolderWithAnEncodedName; it fails without 0328c92);
    • a vouching file listed after two full pages of files that can't vouch is still found, a folder none of whose files vouch stays the stable refusal, and storage errors are told apart from missing, forbidden and out-of-folder paths.

    The two acceptance tests fail on main; the refusal tests pass on both.

  • Database contract for CatalogedFilesUnder (PostgreSQL), added to scripts/ci/db-contracts.txt: present files of the title only, not a sibling folder that shares the name as a prefix, not a missing file, not another title's file; the limit holds.

  • Local package checks: go vet and go test -p 4 -count=1 over ./internal/metadata/ and the folder tests in ./internal/catalog/ against a migrated PostgreSQL 18 database pass. After merging current main (932a166) and the encoding fix (0328c92), go vet ./internal/metadata/ ./internal/catalog/ and go test -p 4 -count=1 ./internal/metadata/ pass; I didn't rerun the database contract locally.

  • Manual run: main and this branch as local dev builds; see Evidence.

  • Review fixes (maintainer review, 1ca1d7e, on a merge of main at 7e0765b): the requeue migration, applied to a migrated PostgreSQL 18 database with seeded rows (refused file:// rows queued and due; missing, running and remote rows untouched); a stale catalogued path with a file where a folder was now gets the stable refusal; a catalogued video linked through another link and .. inside the folder now vouches, and a .. link out of it stays refused. The two new test checks fail on the commits before their fixes. go test ./internal/metadata/, the CatalogedFilesUnder database contract, make migrate-validate and make lint-changed pass.

  • Not run locally: the full Go and web suites. CI runs them.

  • Benchmarks: not applicable. The extra work only runs for an image that would otherwise be refused: one indexed media_files query and a few stat calls per folder between the image and the library root.

Evidence

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

I ran main (0e8277f) and this branch (8e34899a1; later commits change only error handling for failed checks, tests and docs) as local dev builds. The library folder holds one symlink per title into a store folder, and each title folder has a short generated video, a poster.jpg and a movie.nfo. Provider plugins were off, so the titles matched from the NFO only.

main This branch
Local poster jobs Failed: local image path outside library roots, next attempt in 7 days Succeeded
Library page and title page Placeholder posters The local posters
Admin image picker (Edit Metadata > Images) "Could not load from LOCAL", no images The local poster offered

The page has desktop and phone-width captures of all three screens and the job rows. The picker captures come from a rebuild at 5f90877.

Risks

  • Artwork that was refused before now appears for these libraries, replacing provider artwork where local artwork wins today. A migration queues the jobs the old check refused again, including those that had spent their attempts and parked for good, since a refresh doesn't reopen them. A path that is still outside the roots is refused and parks again.
  • Still refused, deliberately: a title folder whose catalogued videos are themselves symlinks out of it (the proof goes through the opened folder, which won't follow them).
  • Not changed: when a linked title folder's target goes missing (a debrid mount dropping), the job fails as "missing" and waits rather than deferring as unmounted storage does. That is the same as before this change.
  • The exception trusts any folder that holds a catalogued file of the title, at any depth below it. A title folder with a catalogued video vouches for images in its subfolders too, the same reach the scanner already has.

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)
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: AI-assisted with Claude Opus. I directed the task and designed the work.
  • Adversarial review: A separate Claude Code agent tried to break the confinement: planted links at several depths, links inside the trusted folder, catalogued files that are themselves links, hard links, person photos, retargeting links between each check (TOCTOU), and the stable-failure texts. It found no escape. I acted on its other points: an I/O error during the check now retries instead of parking, a compile-time check pins that the folder repository provides the listing, and the docs say "below the library root". I kept the two limits it noted, which the Risks section lists.
  • Maintainer review: Claude Code (claude-opus-5-5) with a gpt-6.1-sol second opinion reviewed 0328c92 and added the merge of main and two fix commits (00aa7b6, 1ca1d7e).

Note

Fix local artwork reads in title folders symlinked out of the library

  • Local image-cache jobs previously refused artwork when a title folder symlink resolved outside every library root. Now, when a present cataloged file of the same title exists under the image's physical folder, the folder is opened as an os.Root and the image is read through it; otherwise the read stays refused.
  • Adds FolderRepository.CatalogedFilesUnder to list present cataloged files of a title beneath a directory with cursor-based pagination (limit 32). Cataloged paths with in-folder symlinks are resolved component-by-component, rejecting links that leave the folder or loop.
  • Storage I/O and listing errors are classified as retryable read failures instead of outside-roots refusals. The same fallback applies to the admin local sidecar reader in local_artwork_picker.go.
  • A migration requeues file:// image-cache jobs whose last error was an outside-roots refusal, resetting attempt counts so they retry. Risk: the migration's prefix match on the error text in 20261102003211_requeue_local_artwork_refused_outside_roots.sql resets attempt counts to zero for matching jobs; genuine refusals will fail again after retry.

Macroscope summarized 1ca1d7e.

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

silo-kody Bot commented Oct 16, 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 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Local artwork reads can use a catalog-verified folder when symlink resolution places the image outside library roots. The image cache and admin picker use the same reader. Other unverified paths remain rejected.

Changes: Local artwork through symlinked folders

Layer / File(s) Summary
Cataloged files lookup
internal/catalog/folder_repo.go, internal/catalog/folder_repo_cataloged_files_db_test.go, scripts/ci/db-contracts.txt
Adds a paginated lookup for present files belonging to a title under a directory. The database test checks title and directory scoping, missing-file exclusion, and pagination.
Catalog-verified image reads
internal/metadata/image_cache_processor.go, internal/metadata/image_cache_processor_symlink_test.go, internal/metadata/local_artwork_picker.go, docs/architecture/local-nfo-metadata.md
The image reader checks cataloged files after a symlink escape and reads through an opened folder root only when a cataloged file resolves to the same file. Tests cover accepted paths, rejected paths, and retryable read failures. The admin picker uses the same reader. The architecture documentation describes the rule.

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant ImageCacheProcessor
  participant readLocalImageOfTitle
  participant FolderRepository
  participant osRoot as os.Root
  ImageCacheProcessor->>readLocalImageOfTitle: Read local image
  readLocalImageOfTitle->>FolderRepository: List cataloged files under image folder
  FolderRepository-->>readLocalImageOfTitle: Return present file paths
  readLocalImageOfTitle->>osRoot: Verify cataloged file and read image
  osRoot-->>ImageCacheProcessor: Return image data or read failure
Loading

Suggested reviewers: quick104

Merge Risk: Minimal · up to 0328c

No identified issue blocks merging. A failed local-image preview does not prevent other image choices from appearing.

Security architecture risk: Low · up to 0328c

The change deliberately expands which local artwork folders may be read, but limits that expansion with same-title catalog checks, folder-confined reads, and file-identity checks. No concrete new security weakness was established. Assurance under concurrent filesystem changes remains incomplete.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The authority expansion concerns filesystem-readable artwork in qualifying external folders, subsequently used by artwork caching or admin selection. It is not an unrestricted pathname-read capability: the logical path must belong to an owning library root, and an external candidate folder must pass catalog and filesystem checks. Effective exposure depends on the server's mounts and filesystem permissions.

Security Findings and Attack Paths

  • observed — The inspected counterexamples do not establish a bypass. A planted external link is refused when the title's cataloged video is elsewhere, and a cataloged video symlink leaving the candidate folder does not validate that folder. These cases support the intended distinction between a catalog-backed title folder and an unrelated planted link; they do not establish safety for every concurrent mutation sequence.

Trust Boundaries and Controls

  • observed — Trust is delegated from library-root confinement to same-title catalog evidence plus opened-folder enforcement. The candidate must physically contain the resolved image directory; cataloged paths must resolve without leaving that folder; and the file reached through the opened root must match the current catalog path before the image is read through that root.
  • observed — The identity check compares current filesystem observations. The catalog query supplies paths, content ownership, and present status; it does not supply an immutable inode or content identity recorded at scan time. The design therefore relies on cataloged path ownership rather than media-content immutability.

Resilience and Maintainability Implications

  • observed — Folder and image handles are closed on exit, symlink traversal is bounded, and failed verification does not publish a target update. Successful processing retains the existing sequence of caching, source-conditional target update, and job completion, with displaced artwork handled by the existing reference-aware lifecycle.
Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: enabling local artwork reads for title folders symlinked outside the library.
Linked Issues check Passed Objective [#2552]: cache local artwork beside indexed media when a title folder is a symlink out of the library roots. A symlink planted in the library that points to a directory with no catalogued me…
Out of Scope Changes check Passed Each changed area traces to [#2552]:
- The processor read path and helpers in internal/metadata/image_cache_processor.go implement the trust rule for escaped title folders.
- readConfinedLocalImage …
Description check Passed The description directly explains the local artwork symlink handling changes, catalog verification, admin image picker behavior, tests, validation, risks, and migration.
Full details: Linked Issues check

Explanation

Objective [#2552]: cache local artwork beside indexed media when a title folder is a symlink out of the library roots. A symlink planted in the library that points to a directory with no catalogued media for the title must stay refused.

Evidence at head 0328c92 (whole-PR diff against merge base 0225a05):

  • readLocalImageOfTitle (internal/metadata/image_cache_processor.go) runs readConfinedLocalImage first. Only the errLocalImageEscapedRoots case reaches readCatalogedLocalImage.
  • readCatalogedLocalImage walks from the image folder up to, but not including, the library root. It uses a folder only when the resolved image folder lies inside that folder's resolved path.
  • CatalogedFilesUnder (internal/catalog/folder_repo.go) lists present media_files rows (missing_since IS NULL) for the same content ID under the folder prefix. The processor must find one of them to be the same file through an os.Root opened at the folder (fspath.SameFile). pathInsideFolder refuses a catalogued file that is a link out of the folder.
  • The image is read through that root with readLocalImageFile, which keeps the leaf checks.
  • Storage and listing errors return local image read failed and retry. Otherwise the outside-roots text is kept, so the 7-day park is unchanged.

Coverage: title, season, episode and backdrop artwork use the title or series content ID, as the issue proposes.

Not verified: I did not read the test files, the person .actors content ID path, or the admin picker call site. The PR states these use the same helper. #2552 requires title and series artwork, so these gaps do not change the verdict.

The previous PASS stays supported by the code above.

Full details: Out of Scope Changes check

Explanation

Each changed area traces to [#2552]:

  • The processor read path and helpers in internal/metadata/image_cache_processor.go implement the trust rule for escaped title folders.
  • readConfinedLocalImage only marks the existing outside-roots error so the fallback can find it.
  • CatalogedFilesUnder supplies the catalogue check that the rule needs.
  • Its database contract test and the scripts/ci/db-contracts.txt entry test that query.
  • The admin picker reads local sidecars through the same helper, so its previews match the artwork the scanner accepts.
  • Person .actors photos use the same helper, vouched for by the crediting title's files.
  • docs/architecture/local-nfo-metadata.md documents the confinement rule.

The validation-board entries in the PR description name other issues. They are test records, not code changes, and no other linked issue supplies requirements. The processor and folder repository diffs show no unrelated API, client or feature change.

Not inspected directly: the picker, person, test, documentation and contract-list files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Oct 16, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 16, 2026

Copy link
Copy Markdown

The Evidence section is still a placeholder, but this changes what users see:

  • internal/metadata/image_cache_processor.go: titles, seasons, and episodes in symlinked folders can now show local artwork instead of the previous artwork or no artwork. Please add before-and-after captures of the same item on a client surface, naming the surface and build/commit.
  • internal/metadata/local_artwork_picker.go: the admin picker can now preview local sidecars in those folders. Please add before-and-after captures of the same item in the picker, naming the surface and build/commit.

Suggested fix: replace “Evidence: captures to follow in this section.” with the requested captures or an evidence.siloserver.org link to them.

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 16, 2026

Copy link
Copy Markdown

The Evidence: link and described library/title-page captures cover the newly shown local artwork, but internal/metadata/local_artwork_picker.go also changes what the admin picker previews. The evidence page should show a before-and-after view of the same sidecar in the picker so reviewers can check that visible effect.

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

Posted via Macroscope — Visible change evidence

@blurbery

Copy link
Copy Markdown
Contributor Author

@macroscopeapp The Evidence section now links before-and-after captures from local dev builds of main and this branch, at desktop and phone width: the library page and a title page (placeholder posters before, the local posters after), and the admin image picker under Edit Metadata > Images ("Could not load from LOCAL" before, the local poster offered after). Season and episode images go through the same check; the unit tests cover a series folder vouched for by an episode.

@silo-triage silo-triage Bot added size/XL 500–999 added + deleted lines (all files); change volume, not priority. and removed size/L 200–499 added + deleted lines (all files); change volume, not priority. labels Oct 16, 2026
@silo-kody

silo-kody Bot commented Oct 16, 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 16, 2026 •

Copy link
Copy Markdown

The confinement exception also reaches NFO person-photo jobs: localPersonPhotoJobs records the credited title ID as SeriesID, and processLocalOne passes it to readLocalImageOfTitle. The person endpoint then returns the cached file as photo_url, which first-party clients render. A .actors file in a linked title folder can therefore change the photo/fallback outcome in the passed Person C2 cases. This is a major change; the PR must explain why validated behavior changes, and these cases need re-validation after merge.

Calendar C1 is also affected: the server fills event poster_url from item/season artwork paths, and the Calendar cards display it. A linked-title sidecar can change this displayed data while the release/date assertions remain the same. This is a major change; the PR must explain it, and these cases need re-validation after merge.

Suggested Validation tasks: line: Validation tasks: changes #1143 C5; changes #1144 C2; changes Silo-Server/silo-apple#307 C2; changes Silo-Server/silo-apple#308 C2; changes Silo-Server/silo-android#317 C2; changes Silo-Server/silo-android#318 C2; changes #1136 C1; changes Silo-Server/silo-apple#303 C1; changes Silo-Server/silo-apple#304 C1; changes Silo-Server/silo-android#314 C1; changes Silo-Server/silo-android#313 C1

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

Posted via Macroscope — v1 validation impact

@blurbery

Copy link
Copy Markdown
Contributor Author

@macroscopeapp Agreed that person photos from a title's .actors folder go through the same check, keyed on the crediting title. I updated the Validation tasks: line to list the Person C2/C5 and Calendar C1 cases as reached, but only for libraries whose title folders are symlinks out of the library. There, local photos and artwork now appear where they were refused before, which still meets each case's criterion. Libraries without that layout take the same path as before, so a re-check is only needed if the fixture library uses linked title folders. I also added a sentence about person photos to the Approach section.

@silo-kody

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

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

@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.

Review of b226548. The approach holds up: the confinement checks I and a second reviewer tried to break (planted links at several depths, a folder above the escaping link, prefix-sharing siblings, link loops, a cataloged file that is itself a link out) all stay refused, and the acceptance tests fail on main and pass here. Two findings below, both small. I'm fixing both in a commit on this branch, so there's no need to change anything yourself. The branch also needs a rebase onto main for a db-contracts.txt conflict, which I'm doing in the same push.

@Quick104
Quick104 force-pushed the fix/local-artwork-symlinked-title-folders branch from b226548 to 8cd2997 Compare October 21, 2026 16:35
blurbery and others added 7 commits October 21, 2026 12:36
…library

A library whose title folders are symlinks into another tree, as
download managers and debrid mounts lay them out, had every local
poster, backdrop and episode image refused as outside the library
roots and parked for 7 days. The scanner follows those links and
catalogues the videos behind them, so the artwork beside a video it
plays was the only thing refused.

When an image's folders lead out of every root through a symlink, read
it only when a folder it physically sits in, below the library root,
also holds a present catalogued file of the same title. That folder is
opened as an os.Root, the catalogued file must be the same file reached
through it, and the image is read through it with the usual leaf
checks. Everything else keeps the outside-roots refusal, except that an
I/O error while checking is a read failure retried as usual. The admin
image picker reads sidecars the same way.
The check that lets local artwork through a symlinked title folder had
three gaps. A storage error while checking a cataloged file was
dropped, so a flaky mount parked the job as refused. Only the first 8
cataloged files were tried, and a full batch without a match was taken
as proof that none would match. And the image was read through the
opened folder by its logical path, which os.Root refuses when it goes
through an absolute link, even one that stays in the folder.

Keep storage errors from every step of the check, try up to 32 files
and retry when a full batch has no match, and read both the cataloged
file and the image through the folder by their resolved paths, as
readConfinedLocalImage does.
The previous commit resolved each cataloged file with EvalSymlinks
before checking that it sits in the opened folder, which follows a
video's link out of the folder. A link into a stalled network mount
would then block the worker. Look the file up through the opened
folder first, as before, and stat its cataloged path only once it is
known to be inside. The image keeps its resolved path, so an absolute
link inside the folder still reads.
Looking a cataloged video up through os.Root by its logical path kept a
link out of the folder from being followed, but os.Root also refuses an
absolute link, so a video that is an absolute link to another file in
the same title folder no longer vouched for it. Resolve the video's
path one component at a time inside the folder instead: each link is
read, not followed, and its target must lie in the folder before the
check carries on there. A target outside the folder is refused without
being touched, and a link loop ends the check.
…artwork

The cataloged-file check listed the first 32 files by id and, when none
vouched for the folder, retried the job. Every retry listed the same 32
files, so it could not succeed: a vouching file after them was never
reached, and a folder no file vouches for cycled through retries and
cooldowns instead of parking. Page through every cataloged file under the
folder in path order instead, so the answer is final.

Count only OS storage errors as retryable in the outer check too, as the
inner one does, so a non-errno error such as a symlink loop keeps the
stable refusal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104
Quick104 force-pushed the fix/local-artwork-symlinked-title-folders branch from 8cd2997 to ec063f2 Compare October 21, 2026 16:38
@Quick104

Quick104 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: 0328c92c7, then pushed on top of it: a merge of main (100b7e1b5) and two fix commits, ending at 1ca1d7ee4. My earlier review covered ec063f29b.

Branch updated, not rewritten. main conflicted with this branch in scripts/ci/db-contracts.txt. Both sides only appended entries, so the merge keeps both. Your commits are unchanged.

Addressed in this round

  • Jobs the old check refused never got the fix (medium). An outside-roots refusal retries weekly for 8 attempts and then parks for 100 years. Enqueue reopens a parked job only when its source path changes, so a refresh doesn't help. A new migration queues those file:// jobs again. I ran it on PostgreSQL 18 with seeded rows: the refused rows came back queued and due, and missing, running and remote rows were left alone.
  • ENOTDIR, ELOOP and ENAMETOOLONG counted as storage errors (low). A stale catalogued path turned the stable refusal into a retried read failure. They now count as answers about the path.
  • .. in a link target was applied before the links in it (low). A catalogued video linked as alias/../video.mkv couldn't vouch. .. now steps back from the link-free path resolved so far and is refused at the top of the folder.
  • The PR body's Risks line said a refresh picks the refused jobs up sooner. It now describes the migration.

Checked and holding

  • Tests. The acceptance tests fail on main with local image path outside library roots and pass here. The two new checks fail on the commits before their fixes. go test ./internal/metadata/, the CatalogedFilesUnder database contract (PostgreSQL 18), make migrate-validate and make lint-changed pass. I didn't rerun the live dev-build check. The captures on the evidence page still hold, because none of these fixes changes what those screens show.
  • Content IDs. Item, backdrop, localization, season, episode and person jobs all pass the title or series ID that media_files.content_id carries. The server wires the folder repository as the resolver, so the listing is available in production.
  • Confinement. A second reviewer (gpt-6.1-sol) attacked planted links, encoded names, prefix-sharing folders and links that leave the folder, and found no read outside a vouched folder. A title link retargeted between checks can point the read at another folder that holds a file at the same relative path as the video. Retargeting the link statically does the same, which falls under the trust the PR states.
  • Earlier threads. Kody's threads and mine are addressed. The 0328c92 encoding change uses the fspath wrappers at every file-system call I traced.

Left for maintainers

  • Stalled mounts. The check stats catalogued files in folders the image read doesn't otherwise touch, such as season folders under a series. These calls have no timeout. The second reviewer showed with injected syscall delays that a slow folder holds the worker past its deadline. A real hung mount wasn't reproduced. The image read already has the same exposure on the folder it reads, and a link out of the folder is never followed, so a stalled remote behind a debrid link isn't touched.
  • Layouts still refused, as the PR says: a folder whose catalogued videos are themselves links out of it (common in debrid symlink farms), and an absolute link written through the library path.
  • The other design. The catalog already records each title's folder (canonical_root_path, from the logical path). LibraryRootsForContent could return it, and the existing confinement would accept these images in a few lines, including both layouts above. In exchange it drops this PR's check that the catalogued video is still inside the folder when the image is read, so a title folder swapped for a link after the scan would pass. That trade-off is for maintainers. It doesn't block this PR.

Validation

The validation board couldn't be read: the review token lacks the read:project scope. Reading the task issues instead, I found no passed case this diff changes. The Person and Calendar cases in the body's Validation tasks: line run on fixtures without linked title folders, so their behavior is the same. The line is broader than needed but safe. Re-checking is only worthwhile if a fixture library uses linked title folders.

User manual and clients

The manual needs an update. running-a-server/local-metadata.md gives "the title's folder is a symbolic link to a place outside the library's folders" as the reason Could not load from LOCAL appears. After this PR, those images load when the folder holds a catalogued video of the title. The update is tracked in Silo-Server/siloserver.org#332 and waits for this PR to merge. This is server-only with no API change, so Apple, Android and jellycompat need nothing. They receive the artwork through the existing fields.

Verdict

Fit: 8/10 · Readiness: 9/10 — CI green; documented risks remain for maintainer review

  • Fit: Linked title folders are a common layout for download managers and cloud mounts, and losing all their local artwork is a real gap. The fix keeps the default protection and bases the exception on the trust Silo already uses for transcode inputs. It is held to 8 because it adds a second symlink resolver and per-read catalog checks to the confinement path, where the catalog's recorded title folders might do the job more simply.
  • Readiness: The acceptance tests fail on main, every fix in this round has a check that failed before it, and the author's local run showed the posters appear. The stalled-mount exposure remains an open concern: the added filesystem checks have no timeout, and a real hung mount was not reproduced.

🤖 Generated with Claude Code (claude-opus-5-5) via /silo review, with a second-opinion pass from gpt-6.1-sol.

Coordinator follow-up: Codex (gpt-6-astra) in T3 Code verified the guide and filed the manual issue.

Final check on 1ca1d7ee4: all required CI checks pass, the branch is mergeable, and all review threads are resolved. No approval or merge was performed. Fetched main at 257390ba1; the two commits since this branch's validated base fix unrelated playback/subtitle tests, with no overlap in this PR's production path or dependencies, so another merge is unnecessary. CodeRabbit's summary still covers 0328c92c7; its neutral check does not establish a fresh review of the fixes. Kody completed with no new inline findings, while disclosing four rules it could not evaluate.

The stalled-mount exposure remains documented and was not reproduced on a real hung mount. The alternative confinement design remains a separate maintainer option. Manual follow-up: Silo-Server/siloserver.org#332, to update after merge.

🤖 Codex (gpt-6-astra) in T3 Code.

@silo-kody

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

Main now stores file names that are not UTF-8 in fspath encoding (Silo-Server#2571).
The checks that let a cataloged video vouch for a title folder linked out
of the library passed those encoded paths straight to EvalSymlinks, Stat,
Lstat, Readlink and OpenRoot, so a folder whose name needs encoding was
never found and its artwork stayed refused as outside the library.

Use the fspath wrappers for each call, decode the folder and the in-root
path for os.Root, and compare with fspath.SameFile. The new test links a
title folder whose name needs encoding; it fails without this change.
@silo-kody

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

@blurbery

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the fixes. Since then I've merged current main and switched these checks to the fspath wrappers, now that #2571 stores names that aren't UTF-8 encoded (0328c92, with a test that fails without it).

On the points you left open: the stalled-mount exposure is the same kind of stat the read already does, so I've left it as it is; the narrow layout stays refused, as it is today; and if you'd rather go the scanner-side way (recording each title link's resolved target for LibraryRootsForContent), I'm happy to look at it as a follow-up.

Quick104 and others added 3 commits November 2, 2026 00:17
Keep both appended entries in scripts/ci/db-contracts.txt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…alog paths

Jobs the old confinement refused as outside the library roots waited a
week between attempts and, once their attempts were spent, parked for
good: enqueue reopens a parked job only when its source path changes,
so libraries that had hit the refusal long enough never got the fix. A
migration queues those jobs again now.

A cataloged path that is no longer shaped as recorded (a file where a
folder was, a link loop, a name too long) is an answer about the path,
not a storage failure, so it no longer turns the stable refusal into a
read failure retried on the short backoff.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pathInsideFolder cleaned a link target before resolving the links in it,
so "alias/../video.mkv" with alias pointing at payload/sub became
"video.mkv" again instead of payload/video.mkv. The check looped and a
cataloged video inside the title folder could not vouch for it. A ".."
now steps back from the link-free path resolved so far and is refused
above the folder.

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

@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.

Review of 0328c92, the encoding change and the merged main since my earlier review of ec063f2.

The approach still holds. The acceptance tests fail on main with the outside-roots refusal and pass here. The database contract test passes on PostgreSQL. Three findings below, one medium and two low. I'm fixing all three in commits on this branch, so there's no need to change anything yourself.

The branch also conflicted with main in scripts/ci/db-contracts.txt. Both sides only appended entries, so I'm merging main and keeping both, without rewriting your commits.

🤖 Generated with Claude Code (claude-opus-5-5) via /silo review.

@silo-kody

silo-kody Bot commented Nov 2, 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
Quick104 merged commit b7aa5b0 into Silo-Server:main Nov 2, 2026
22 checks passed
@blurbery
blurbery deleted the fix/local-artwork-symlinked-title-folders branch November 6, 2026 00:01
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 priority: P2 Limited scope, workaround exists, or polish size/XL 500–999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Local artwork in symlinked title folders is refused as outside the library roots

2 participants