Skip to content

feat(metadata): local NFO metadata and sidecar artwork (builtin chain provider) - #390

Merged
Quick104 merged 5 commits into
mainfrom
feat/local-metadata-nfo
Jul 16, 2026
Merged

Quick104 merged 5 commits into
mainfrom
feat/local-metadata-nfo

Conversation

@CoffeeKnyte

@CoffeeKnyte CoffeeKnyte commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Three commits: two feature phases and one architecture-doc consolidation, together
delivering local .nfo metadata and sidecar artwork for movie, TV, and mixed libraries —
disabled by default, with an in-branch multi-angle adversarial review folded in.

Part of #216

Problem

Curated libraries sat unmatched. A movie or show with an intentionally prepared
movie.nfo/tvshow.nfo and a poster.jpg next to it — the standard Kodi/Jellyfin
layout — was invisible to Silo's matcher. If the title wasn't found online (or didn't
exist online at all), the item stayed "unmatched" in the library forever, showing a bare
filename and no artwork, even though everything needed was sitting right beside the file.

Whole categories of content could never work. Fitness programs (a P90X library with
courses and sessions), sports (WWE pay-per-views, NASCAR, F1, FIFA), courses, and home
video have no TVDB/TMDB entries or only partial ones. Operators had no way to give Silo
that metadata; the library pages showed skeletons.

Local posters had no path into the system. Even when an item matched, a curated
poster.jpg on disk was ignored — only downloaded artwork was ever shown, on every
client.

Solution

Local NFO metadata ships as a builtin provider in the existing per-library provider
chain
— visible and orderable in the chain editor next to TMDB/TVDB, disabled by
default everywhere
(zero behavior change until an admin enables it). Design record:
docs/architecture/local-nfo-metadata.md; admin usage in
docs/wiki/admin/nfo-local-metadata.md.

feat(metadata): register builtin NFO provider and broaden parsing

A reserved kind='builtin' row in plugin_installations (migration
20260712100125_builtin_host_providers.sql) lets the dormant internal/metadata/nfo
provider participate in chains without relaxing any FK; buildProviders
(internal/metadata/chain.go) returns the in-process provider for builtin rows. Guard
rails keep the row out of every plugin surface (user settings, installations list, image
resolvers, preload, auto-update, store delete, and all mutation handlers — including
the auth- and task-binding endpoints, plugins.go:1051/1084). Identity is hint-first:
NFO <uniqueid> values seed the trusted-hint machinery before remote search, so a curated
ID unlocks full remote enrichment even when title search fails, while ID-less NFO
candidates are defanged so they can never downgrade a working remote match. A startup sync
appends the capability (disabled) to existing chains and materializes legacy
content_level='' chains; the chain-less fallback now respects default_enabled=false
(pre-existing #294-class bug). The parser covers the practical Kodi/Jellyfin field set
(nfo/nfo.go); findNFO falls through on parse failure or root-type mismatch and
GetMetadata gains the same content-type guard as Search, so a stray tvshow.nfo can
never inject series data into a movie. A new FieldReleaseDates lock protects
admin-corrected dates from manual-refresh overwrite (Go merge + web dialog).

Review-hardening folded into this commit: the builtin-kind check on the hot chain path is
now served from the plugins service's in-memory cache (InstallationKind) instead of a
per-capability SELECT; person-refresh resolution honors default_enabled=false;
<uniqueid type="themoviedb"> and RT ratings without a max attribute parse correctly;
year-only/datetime <premiered> still derives the year; the Edit-metadata dialog maps
Countries to the correct field lock; and a manual refresh of a provider-anchored item
whose corrected <uniqueid> derives a new anchor now re-anchors the content_id itself
(rename, or merge onto the existing holder) — not just the stored provider IDs.

feat(metadata): ingest local sidecar artwork and read series-depth NFO

The provider implements ImageProvider; sidecar images become file:// sources routed
through the existing image-cache pipeline into S3 under
local/{contentType}/{contentID}/{hash8}/{imageType}/… — clients always receive normal
presigned URLs, and library files are never served directly. season.nfo supplies season
names/plots, <basename>.nfo + <basename>-thumb.ext supply episode metadata and thumbs,
and season posters resolve from Season NN/poster.ext / seasonNN-poster.ext. Naming
owns structure
: NFO season/episode numbers are advisory and filename/directory-derived
numbers win with a warning. Episode NFOs work without a season.nfo; synthesized fallback
episodes still cover NFO-less files. A second migration
(20260712124741_nfo_capability_season_episode_levels.sql) adds season/episode levels to
the capability. Behavior pins prove the mixed-library composition (movie-shaped events and
show-shaped weeklies in one library) works with no code changes.

Review-hardening folded into this commit: a manual Identify now skips the NFO provider
across every phase — images, seasons, and episodes, not only metadata — so a stale sidecar
cannot overlay art, season names, or episode titles onto the user's chosen identity; an
artwork-only season/episode (a thumb/poster with no .nfo) now keeps its
"Season N"/"Episode N" fallback title instead of persisting blank; sidecar-cache read
confinement adds a symlink-resolving re-check that rejects an intermediate directory
symlink escaping a library root (while symlinked roots stay valid and symlinked leaves
stay rejected); and structurally-unusable sidecars (non-regular / over the size cap) are
now stable failures instead of retrying indefinitely.

docs(metadata): document local NFO metadata architecture

One tracked architecture reference (docs/architecture/local-nfo-metadata.md), an admin
wiki page with worked fitness and sports layouts, sidecar-naming updates, and a v1-scope
feature-detection note. Planning drafts stay untracked; this PR body carries the scenario
matrix.

Behavior by scenario

Legend: ✅ works end to end (pinned by tests) · ⚠️ works, with nuance worth knowing ·
🚧 known gap / deferred.

Movies & identity

Scenario Behavior
Movie with title-only NFO, nothing online ✅ Matched under a local: content id; NFO title/plot/genres applied; poster served from S3. Leaves the match queue.
NFO carries a tmdb/imdb/tvdb <uniqueid>, title search fails ✅ Trusted hint anchors the real remote match; full remote enrichment (cast, images, episodes) by ID.
Remote search finds the movie and a title-only NFO exists ✅ Remote match kept — an ID-less NFO can never downgrade it; NFO fields overlay per chain priority.
Wrong <uniqueid> in the NFO, fixed on disk ✅ Manual Refresh metadata re-anchors: the stored provider IDs and the content_id rebind (renamed to the corrected anchor, or merged onto the item already holding it). Scheduled refresh never flips an anchored identity in the background.
Manual Identify to override a wrong NFO ✅ User's choice wins; the NFO provider is skipped for the whole operation — metadata, images, seasons, and episodes — so no stale art or titles bleed through. A later manual refresh re-trusts the NFO; fix or delete the file if it's wrong.
Editing NFO title/plot after match ⚠️ Propagates on manual refresh only; the scheduled refresh fills empty fields but does not overwrite. Documented in the wiki.

Series & structure

Scenario Behavior
Show absent from TVDB with tvshow.nfo ✅ Show titled and arted from the series root.
Fitness library (P90X): courses as named seasons, sessions as episodes ✅ Full tree from NFOs: named seasons, titled episodes, season posters, episode thumbs — zero remote IDs. Structure comes from Season NN/SxxEyy naming; NFOs supply metadata only.
Episode or season with artwork but no .nfo ✅ Appears with its Episode N / Season N fallback title and its -thumb/poster art — partially curated libraries degrade gracefully.
NFO season/episode number disagrees with the filename ⚠️ Filename/directory number wins; the mismatch is logged, never used to relocate metadata.
Multi-episode file (S01E01E02) or multi-<episodedetails> document ⚠️ First block is used and a warning logged; no crash or cross-assignment. Second episode of a combined file gets no NFO row (see gaps).

Mixed libraries (sports)

Scenario Behavior
PPV events as movies + a weekly show, one library ✅ Per-file lanes (no SxxEyy → movie, SxxEyy → series); NFO provider seeded at every level; ID-bearing events enrich remotely next to NFO-only ones.
tvshow.nfo accidentally next to a movie file ✅ Ignored by the root-element type guard — never injected. Misclassified groups are corrected with the per-root Type override + rescan; an NFO cannot flip an item's type.

Sidecar artwork

Scenario Behavior
Enabling NFO art on an already-matched library ✅ Local art applies on the next refresh (rating-0 local exemption in the final image write); it cannot stickily displace higher-priority remote art.
Editing poster.jpg after caching ✅ Manual refresh re-caches under a new content-hash key, rotates jellycompat image tags, deletes the stale S3 prefix.
Deleted / unreadable poster.jpg ⚠️ Stable failure with a long deferral (no hot retry); recovery is refresh-driven.
Non-regular (fifo/device/symlink-leaf) or over-8 MiB sidecar ⚠️ Rejected and classified as a stable failure — no indefinite retry loop.
Intermediate directory symlink escaping a library root ✅ Rejected: confinement resolves symlinks on both path and roots, so an out-of-root target can't be pulled into the public cache. Legitimately symlinked roots still work.
Shared folder.jpg in a flat folder holding several movies ⚠️ Applies to none of them (by design); <basename>-poster.jpg always attaches to its file.

Compatibility & safety

Scenario Behavior
Provider disabled (the default) ✅ Zero behavior change — pinned by CI-mode suites, legacy-chain fixtures, and unchanged GET /settings/plugins / GET /plugins/installations responses.
Plugin-less server ✅ Chain editor is reachable (gate is server-derived), so NFO can be enabled with no plugins installed.
Any plugin-management call against the builtin row ✅ Rejected (409) across every surface, including auth/task bindings; the row is never listed to users, but the chain enabled-check still sees it.
jellycompat / Android / Apple clients ✅ No client changes needed — same presigned image URLs; item provider IDs remain tmdb/imdb/tvdb only.

Known limitations / deferred

Scenario Behavior
Audiobooks / ebooks 🚧 Out of scope — those ecosystems use OPF/metadata.json, not NFO; the builtin registry is the extension point for future local providers.
Admin image picker 🚧 Local art flows through the automatic chain path only; the picker does not list local files.
Multi-part movies (CD1/CD2) sharing one basename-mismatched NFO in a multi-group folder 🚧 Not found; directory-level NFOs cover the common layout.
S00E00 / air-date-only "specials" driven by an NFO 🚧 Silently skipped: naming has no episode-presence flag (EpisodeNum == 0 means "absent" codebase-wide), so E00 support needs a scoped naming + scanner change — deferred to its own PR.

Risk / follow-ups

  • Mixed-version deployments (old binary + these migrations applied) re-expose the
    default_enabled=false fallback bug and would gRPC-construct the builtin row — release
    notes must warn; Goose Down is the escape hatch.
  • The image-cache processor host must mount the media libraries at the scanner's paths
    (documented in the architecture page); otherwise local artwork jobs fail until mounted.
  • Legacy content_level='' chain materialization touches admin data for old libraries;
    order/enabled-preserving by construction and pinned by a fixture test.
  • The anchored→anchored content_id re-anchor leaves series children on their previously
    derived ids (the pre-existing recomposeSeriesChildIDs follow-up); FK integrity is
    intact.
  • Deferred follow-ups surfaced by the review: S00E00 NFO specials (above), the flat-layout
    season inheriting the show poster, the double fallback-synthesis pass (idempotent, minor),
    and the pre-existing flat multi-movie movie.nfo cross-apply.
  • Live jellycompat end-to-end check on a dev deployment still recommended before release.

Verification

  • go build ./..., go vet ./..., gofmt clean; go test ./internal/metadata/... ./internal/api/handlers/... ./internal/plugins/... green (incl. the mixed-library and
    NFO-only fitness-library integration pins).
  • prettier --check and eslint clean on the one changed web file.
  • Reviewed by a five-angle adversarial pass (registration/guard-rails, hint-first identity,
    sidecar artwork/path-confinement, parser/merge, series depth/mixed) with each confirmed,
    in-scope finding fixed and folded into its owning commit.
  • DB-gated suites (ephemeral migrated Postgres) still recommended in CI: migration seed,
    chain resolution through the real enabled-check, legacy materialization, local-artwork
    attribution.

AI-use disclosure

Planned, specified, implemented (TDD), adversarially reviewed, and hardened with Claude
Code (Fable 5 for the feature work; Opus for the multi-agent review) — multi-agent
exploration, per-angle adversarial review, and agent-assisted implementation; all changes
human-directed and verified by the suites above.

Summary by CodeRabbit

  • New Features
    • Added built-in local NFO metadata support for movies, series, seasons, and episodes, including trusted ID hints and sidecar artwork discovery.
    • Added local file:// sidecar artwork caching, including recache rotation and stale prefix cleanup.
    • Added “release-date” field locking (year, release/air/last air dates) in metadata editing.
  • Bug Fixes
    • Built-in provider installations are now immutable and hidden from user plugin settings/listings; protected API operations return 4xx when attempted.
  • Documentation
    • Added/expanded architecture and wiki docs for Local NFO Metadata, artwork naming, and provider discovery (capability-based endpoints).

Phases A and B of the #216 local-NFO work, implemented test-first.

Registration & hint-first identity (Phase A):
- Migration seeds a reserved kind='builtin' silo.builtin installation
  and an 'nfo' metadata capability (default_enabled=false, priority 1
  for movie/series) with a partial unique index and documented Down.
- In-process builtin provider registry (internal/metadata/builtin.go);
  buildProviders returns the registered provider for builtin rows.
- Guard rails keep the reserved row out of every plugin surface (user
  plugin-settings, installations list, image resolvers, preload,
  auto-update, store Delete, mutation handlers -> 409); silo.builtin is
  a reserved manifest id.
- Startup sync materializes legacy content_level='' chains per level,
  then appends builtin capabilities disabled via
  AppendProviderToAllChains (idempotent); resolveEnabledProvidersBy
  priority now respects default_enabled=false.
- NFO uniqueids seed the trusted-hint machinery via IdentityHintProvider
  with per-mode conflict policy (stored IDs win on scheduled refresh,
  NFO wins on manual refresh, Identify skips NFO); ID-less candidates
  are excluded from provider-priority tie-breaks and nfo never counts
  as corroboration.
- Web chain-editor empty-state gate is now server-derived so builtin
  providers are reachable on plugin-less servers.

Parser breadth & sidecar hardening (Phase B):
- Parser covers the practical Kodi/Jellyfin field set for <movie> and
  <tvshow>: original title, tagline, runtime, dates, content rating,
  genres/studios/countries/tags, multi-source ratings with scale
  normalization, cast with roles/order, director/credits. Empty
  collections stay nil so merge early-returns apply.
- findNFO parses candidates and falls through on read/parse failure or
  root-type mismatch, so a stray movie.nfo cannot shadow tvshow.nfo;
  GetMetadata gains the same ContentType guard Search has.
- New FieldReleaseDates lock gates Year/ReleaseDate/First+LastAirDate
  in merge (Go) and the edit-metadata dialog (web), closing the gap
  where a manual refresh re-applied NFO dates over admin corrections.
- Merge-contract tests pin NFO fill semantics, genres whole-list
  first-provider-wins, and NFO edits propagating on manual refresh only.
- Docs: new admin wiki page (supported fields, merge semantics,
  naming-supplies-structure contract), index bullet, sidecar wording
  revision, v1-scope feature-detection note.

Zero behavior change while the provider is disabled (default); pinned
by CI-mode and DB-gated test suites.

Part of #216

AI-use disclosure: implemented with Claude Code (Fable 5) via
spec-driven TDD and agent-assisted implementation.
Phases C and D of the #216 local-NFO work, implemented test-first, plus
the mixed-library use-case pins. Together these deliver the headline
case: a series absent from every remote database (e.g. a fitness
library) scans into a fully presented show -> named seasons -> titled
episodes tree from NFO files and sidecar art alone.

Local sidecar artwork through the S3 image cache (Phase C):
- The NFO provider implements ImageProvider: poster/backdrop/logo
  sidecar discovery with a fixed precedence map, symlink/non-regular
  rejection, an 8 MiB cap, and file:// source URLs at rating 0. Generic
  filenames apply only via the sidecar search paths, so a shared
  folder.jpg in a flat multi-movie directory applies to none.
- file:// becomes a live local source scheme: routed into *_source_path
  (never *_path), accepted by every image enqueue gate, attributed as
  provider "local", excluded from cached-path detection.
- The image-cache processor caches local files with lexical-on-logical
  confinement to the library roots, open-handle reads with re-checks,
  the same variant widths as remote art, and stable (7-day) failure
  classification. Keys land under
  local/{contentType}/{contentID}/{hash8}/{imageType}; superseded
  prefixes are cleaned on re-cache and item deletion.
- applyIfBetter gains a local exemption so rating-0 local art can fill
  matched items without being stickily displaced; ImageRequest carries
  additive sidecar path context.

Series depth (Phase D):
- SeasonsRequest/EpisodesRequest carry additive local path context
  (series roots, per-season directories, per-episode file paths),
  derived from naming at match time and reconstructed on refresh.
- season.nfo supplies season name/plot; NFO season numbers are advisory
  (directory-derived number wins with a Warn - naming owns structure).
  <episodedetails> gains aired/runtime/ratings; <basename>.nfo titles
  episodes and <basename>-thumb.ext supplies thumbs; filename SxxEyy
  wins over NFO numbers.
- Episode NFOs work without a season.nfo (provider seasons unioned with
  on-disk seasons); SynthesizeFallbackEpisodes always runs after persist
  so NFO-less episodes keep synthesized rows. Season/episode file:// art
  rides the Phase C pipeline unchanged.
- Migration adds season:1/episode:1 to the builtin NFO capability's
  default_priority (still default_enabled=false).

Mixed sports-library use case (tests only, no product change):
- Pins the classification contract for one library holding movie-shaped
  and show-shaped content (WWE PPV events as movies next to a "WWE
  SmackDown" show, NASCAR/F1/FIFA with partial TVDB/TMDB data): naming
  decides movie-vs-series per file before any provider runs; the NFO
  supplies metadata/identity but never flips type (ContentType guard);
  the per-root Type override is the correction path.
- NFO-driven type classification at scan time is recorded as an explicit
  deferred open question.

Part of #216

AI-use disclosure: implemented with Claude Code (Fable 5) via
spec-driven TDD and agent-assisted implementation.
Add a single as-built architecture page
(docs/architecture/local-nfo-metadata.md) for the #216 local-NFO
feature: the builtin registration model, hint-first identity semantics,
the file:// -> S3 artwork pipeline and its deployment constraint, series
depth, the mixed-library classification contract, and known limitations.

This replaces the working implementation plan, the per-phase specs, and
the narrow sidecar-artwork note, which were planning drafts and are left
untracked; admin-facing behavior remains in the wiki.

Part of #216

AI-use disclosure: planned, drafted, and consolidated with Claude Code
(Fable 5) using multi-agent exploration and adversarial review.
@CoffeeKnyte
CoffeeKnyte requested a review from Quick104 as a code owner July 13, 2026 00:30
@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c780c3fb-fa29-4190-af60-2f4f95b4d2d6

📥 Commits

Reviewing files that changed from the base of the PR and between 1663aec and 7756ab7.

📒 Files selected for processing (12)
  • cmd/silo/main.go
  • docs/wiki/admin/media-folder-and-naming.md
  • internal/api/handlers/libraries.go
  • internal/api/handlers/plugins.go
  • internal/catalog/folder_repo.go
  • internal/imagecache/imagecache.go
  • internal/metadata/builtin.go
  • internal/metadata/image_cache_processor.go
  • internal/metadata/service.go
  • internal/metadata/types.go
  • internal/plugins/installation.go
  • web/src/components/EditMetadataDialog.tsx

📝 Walkthrough

Walkthrough

Changes

Built-in NFO metadata registration, chain synchronization, identity matching, sidecar artwork discovery, local S3 caching, built-in installation protection, API and web updates, migrations, tests, and documentation were added or updated.

Local NFO metadata

Layer / File(s) Summary
Built-in provider and chain integration
internal/metadata/*, internal/plugins/*, cmd/silo/main.go, migrations/sql/*
Registers the NFO provider in-process, synchronizes provider chains, and excludes immutable built-in installations from plugin operations.
NFO parsing and metadata flow
internal/metadata/nfo/*, internal/metadata/service.go, internal/metadata/match_candidates.go
Parses movie, series, season, and episode NFO files; applies identity hints; integrates merge, refresh, and series-depth behavior.
Local artwork caching
internal/metadata/image_cache_processor.go, internal/imagecache/*, internal/catalog/*
Discovers local artwork, validates library-root confinement, caches bytes using discriminated keys, and removes stale cached prefixes.
API, web, tests, and documentation
internal/api/handlers/*, web/src/components/*, docs/*, internal/**/*_test.go
Exposes built-in installation kinds, updates metadata locks and provider detection, and documents and tests the new behavior.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Scanner
  participant NFOProvider
  participant MetadataService
  participant ImageCacheProcessor
  participant S3
  Scanner->>NFOProvider: Read NFO and sidecar artwork
  NFOProvider->>MetadataService: Return metadata, identity hints, and file:// images
  MetadataService->>ImageCacheProcessor: Enqueue local artwork cache jobs
  ImageCacheProcessor->>S3: Cache image bytes under discriminated local prefix
Loading

Possibly related PRs

Suggested labels: v1

Suggested reviewers: quick104

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 49.32% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: builtin local NFO metadata and sidecar artwork support.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/local-metadata-nfo

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.

@coderabbitai coderabbitai Bot added the v1.0 Silo v1 scope - auto-adds to the Silo v1 project label Jul 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1663aec7e1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

in.SourcePath = strings.TrimSpace(in.SourcePath)
in.TargetLanguage = strings.TrimSpace(in.TargetLanguage)
if in.SourcePath == "" || !strings.Contains(in.SourcePath, "://") || isNonProviderImageScheme(strings.ToLower(in.SourcePath)) {
if !isCacheableImageSourcePath(in.SourcePath) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Requeue local artwork when the file path is unchanged

When a user replaces a sidecar in place (for example overwrites poster.jpg with a new image), refresh rediscovers the same file://.../poster.jpg source and this now passes validation into the normal EnqueueBatch path. That path uses requeueSucceeded=false, and the ON CONFLICT update leaves an existing succeeded job untouched when source_path is unchanged, so the processor never reruns to compute the new content hash/upload the new art; local artwork only updates if the DB job is pruned or the filename changes.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Valid gap, deferring to a follow-up rather than folding it in here. A correct fix has to teach the ON CONFLICT status CASE to treat mutable local file:// sources differently from content-stable remote URLs — requeuing a succeeded job whenever the source is local even though source_path is unchanged — otherwise every enqueue would reprocess unchanged local art too. That tradeoff (and where to draw the local-vs-remote line in SQL) deserves its own scoped change and test, not a rushed inline edit. Note the background reconciliation sweep (EnqueueExistingProviderArtwork, requeueSucceeded=true) does eventually re-run succeeded local jobs, so in-place edits are not permanently stuck. Tracked as a follow-up.

if info.Size() > maxLocalImageSourceBytes {
return nil, fmt.Errorf("local image exceeds %d byte limit: %s", maxLocalImageSourceBytes, path)
}
file, err := os.Open(path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Close the symlink swap window before reading local artwork

When a library directory is writable by a less-trusted user, the sidecar can be swapped after the Lstat check but before this os.Open; os.Open follows symlinks, and the later file.Stat() only verifies that the resolved target is a regular file. That race bypasses the intended leaf-symlink rejection and can cause the cache worker to copy a readable file outside the library roots into object storage; use a no-follow open or verify the opened file's device/inode against the Lstat result.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 82cc5ab. readLocalImageFile now rejects the opened handle unless os.SameFile(info, stat) confirms it is the exact file Lstat inspected. If the leaf is swapped to a symlink between Lstat and os.Open, the followed target no longer matches the original dev/inode and the read is rejected before any bytes reach the cache. Chose os.SameFile over O_NOFOLLOW since it also catches a swap to a different regular file and stays portable.

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/imagecache/imagecache.go (1)

174-210: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

CacheBytes is missing the episode/season consistency check present in Cache.

Cache (Line 224-226) rejects EpisodeNumber != nil && SeasonNumber == nil, but CacheBytes — the path used by the new local sidecar art pipeline for season/episode stills — has no equivalent check. If a caller sets EpisodeNumber without SeasonNumber, buildBasePath silently drops the episode segment (it's only appended inside the SeasonNumber != nil branch), which can collide different episodes' cached art under the same S3 key instead of failing loudly.

🐛 Proposed fix
 	if len(data) == 0 {
 		return nil, fmt.Errorf("imagecache: image data is empty")
 	}
+	if req.EpisodeNumber != nil && req.SeasonNumber == nil {
+		return nil, fmt.Errorf("imagecache: episode number requires a season number")
+	}
 	thumbhash, err := imageutil.Thumbhash(data)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/imagecache/imagecache.go` around lines 174 - 210, Update CacheBytes
to reject requests where EpisodeNumber is set while SeasonNumber is nil,
matching the existing validation in Cache before calling buildBasePath. Return
the same validation error used by Cache, while preserving the current behavior
for valid season/episode and non-episode requests.
🧹 Nitpick comments (7)
cmd/silo/main.go (1)

1157-1165: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Startup DB call has no timeout guard.

SyncBuiltinProviderChains runs on appCtx (unbounded) and log.Fatalfs on error, but unlike the migration steps above (database.MigrationContext(ctx)), it has no deadline. A slow/stuck DB round-trip here hangs startup indefinitely instead of failing fast.

♻️ Proposed fix: bound the sync call with a timeout
 		chainRepo := metadata.NewChainRepository(deps.DB)
-		if err := metadata.SyncBuiltinProviderChains(appCtx, chainRepo); err != nil {
-			log.Fatalf("sync builtin provider chains: %v", err)
-		}
+		syncCtx, syncCancel := context.WithTimeout(appCtx, 30*time.Second)
+		syncErr := metadata.SyncBuiltinProviderChains(syncCtx, chainRepo)
+		syncCancel()
+		if syncErr != nil {
+			log.Fatalf("sync builtin provider chains: %v", syncErr)
+		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/silo/main.go` around lines 1157 - 1165, Wrap the
SyncBuiltinProviderChains call in the startup path with a bounded timeout
context, following the existing MigrationContext timeout pattern. Pass that
derived context instead of the unbounded appCtx, ensure the timeout is canceled,
and retain the existing log.Fatalf error handling.
internal/api/handlers/plugins_builtin_test.go (1)

143-170: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extend builtin-rejection coverage to the other guarded endpoints.

Only delete and update are exercised here, but HandleApplyUpdate, HandlePutInstallationConfig, HandleTestInstallationConfig, HandlePutAuthBinding, and HandlePutTaskBinding were also given builtin-rejection guards in plugins.go. Consider adding cases to this table for those handlers, and asserting the exact 409/builtin_installation response rather than a broad 4xx range.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/api/handlers/plugins_builtin_test.go` around lines 143 - 170, The
TestBuiltinInstallationMutationsRejected table currently covers only delete and
update; add cases invoking HandleApplyUpdate, HandlePutInstallationConfig,
HandleTestInstallationConfig, HandlePutAuthBinding, and HandlePutTaskBinding
with the seeded builtin installation. Update each assertion to require HTTP 409
and verify the response identifies the builtin_installation rejection,
preserving the existing coverage for delete and update.
internal/metadata/builtin.go (1)

40-47: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Silent no-op on invalid registration input.

RegisterBuiltinProvider quietly drops calls with an empty capabilityID or nil construct. Since registration only happens from package init() (per the comment above), a bug there would silently disable a provider with no diagnostic signal.

♻️ Suggested fix
 func RegisterBuiltinProvider(capabilityID string, construct func() Provider) {
 	if capabilityID == "" || construct == nil {
-		return
+		panic("metadata: RegisterBuiltinProvider called with empty capabilityID or nil constructor")
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/metadata/builtin.go` around lines 40 - 47, Update
RegisterBuiltinProvider to emit a diagnostic when capabilityID is empty or
construct is nil before returning, while preserving the existing validation and
registration behavior for valid inputs.
internal/imagecache/imagecache.go (1)

174-226: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate validation between CacheBytes and Cache.

Both methods repeat the same ProviderID/ContentType/ContentID checks. Extracting a shared validateCacheRequest(req) helper would remove the duplication and, combined with the fix above, guarantee the episode/season check can't drift out of sync again.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/imagecache/imagecache.go` around lines 174 - 226, The CacheBytes and
Cache methods duplicate request validation. Extract a shared
validateCacheRequest(req) helper containing the common ProviderID, ContentType,
ContentID, and episode/season validation, then call it from both methods and
remove their repeated checks, preserving the existing validation errors and
behavior.
internal/metadata/image_cache_job_repo.go (2)

483-507: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Fragile SQL text substitution to derive the cached-path query.

strings.Replace(query, "_source_path", "_path", 1) assumes currentTargetSourceQuery always emits exactly one _source_path occurrence, in the expected position. This works today but is a silent-breakage risk if that query's shape ever changes (e.g. a COALESCE over two _source_path columns) — the doc comment states this result is later used to delete stale cached files, so a wrong column could mean deleting/skipping the wrong file with no error surfaced.

♻️ Suggested direction: parameterize the column suffix instead of string-replacing
-func currentTargetSourceQuery(job *models.MetadataImageCacheJob) (string, []any, bool) {
+func currentTargetColumnQuery(job *models.MetadataImageCacheJob, columnSuffix string) (string, []any, bool) {
     // build query using columnSuffix ("_source_path" or "_path") directly
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/metadata/image_cache_job_repo.go` around lines 483 - 507, Update
CurrentTargetCachedPath and currentTargetSourceQuery so the selected column
suffix is provided as an explicit parameter, allowing the cached-path query to
request _path directly instead of deriving it with strings.Replace. Preserve the
existing target-type handling, arguments, and no-row behavior for both
source-path and cached-path callers.

80-97: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Hoist the retry-classification strings into shared constants.

internal/metadata/image_cache_processor.go emits the same local-image failure texts that isStableProviderImageFailure matches here, so a wording change can silently flip retry behavior. Shared constants or sentinel errors would make that coupling explicit and safer.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/metadata/image_cache_job_repo.go` around lines 80 - 97, Define
shared constants or sentinel errors for the local-image failure messages
currently matched by isStableProviderImageFailure, and update
image_cache_processor.go to emit those shared values instead of duplicating
string literals. Update the classifier to match the shared symbols while
preserving the existing stable-failure categories and retry behavior.
migrations/sql/20260712100125_builtin_host_providers.sql (1)

15-21: 🚀 Performance & Scalability | 🔵 Trivial

Non-concurrent index/column DDL is acceptable here, but note the CONCURRENTLY caveat.

Squawk flags the non-concurrent CREATE UNIQUE INDEX/DROP INDEX and the DROP COLUMN in the down migration. Given plugin_installations is a small control-plane table, the lock duration is negligible in practice. Worth noting for future large-table migrations: CREATE INDEX CONCURRENTLY cannot run inside goose's default per-file transaction without a -- +goose no transaction annotation and the index statement isolated in its own file, so simply adding CONCURRENTLY here would break the migration as currently structured.

Also applies to: 48-52

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@migrations/sql/20260712100125_builtin_host_providers.sql` around lines 15 -
21, Keep the non-concurrent index and column DDL in this migration unchanged,
since plugin_installations is a small control-plane table; do not add
CREATE/DROP INDEX CONCURRENTLY without restructuring goose transaction handling.
Apply the same decision to the corresponding down-migration statements for
idx_plugin_installations_builtin_plugin_id and the dropped kind column.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/wiki/admin/media-folder-and-naming.md`:
- Around line 202-208: Update the NFO support paragraph to accurately state that
season and episode NFO files, along with supported sidecar artwork such as
season posters and episode thumbnails, are actively read and cached by the
metadata pipeline. Keep the existing statements about trusted provider IDs,
grouping behavior, and the Local NFO Metadata link unchanged.

In `@internal/plugins/installation.go`:
- Around line 22-54: Update the installation store’s Update operation to load or
inspect the target installation and return ErrBuiltinInstallationImmutable when
Installation.IsBuiltin() is true. Apply this guard before any fields or
capabilities are rewritten, while preserving the existing update behavior for
non-builtin installations.

---

Outside diff comments:
In `@internal/imagecache/imagecache.go`:
- Around line 174-210: Update CacheBytes to reject requests where EpisodeNumber
is set while SeasonNumber is nil, matching the existing validation in Cache
before calling buildBasePath. Return the same validation error used by Cache,
while preserving the current behavior for valid season/episode and non-episode
requests.

---

Nitpick comments:
In `@cmd/silo/main.go`:
- Around line 1157-1165: Wrap the SyncBuiltinProviderChains call in the startup
path with a bounded timeout context, following the existing MigrationContext
timeout pattern. Pass that derived context instead of the unbounded appCtx,
ensure the timeout is canceled, and retain the existing log.Fatalf error
handling.

In `@internal/api/handlers/plugins_builtin_test.go`:
- Around line 143-170: The TestBuiltinInstallationMutationsRejected table
currently covers only delete and update; add cases invoking HandleApplyUpdate,
HandlePutInstallationConfig, HandleTestInstallationConfig, HandlePutAuthBinding,
and HandlePutTaskBinding with the seeded builtin installation. Update each
assertion to require HTTP 409 and verify the response identifies the
builtin_installation rejection, preserving the existing coverage for delete and
update.

In `@internal/imagecache/imagecache.go`:
- Around line 174-226: The CacheBytes and Cache methods duplicate request
validation. Extract a shared validateCacheRequest(req) helper containing the
common ProviderID, ContentType, ContentID, and episode/season validation, then
call it from both methods and remove their repeated checks, preserving the
existing validation errors and behavior.

In `@internal/metadata/builtin.go`:
- Around line 40-47: Update RegisterBuiltinProvider to emit a diagnostic when
capabilityID is empty or construct is nil before returning, while preserving the
existing validation and registration behavior for valid inputs.

In `@internal/metadata/image_cache_job_repo.go`:
- Around line 483-507: Update CurrentTargetCachedPath and
currentTargetSourceQuery so the selected column suffix is provided as an
explicit parameter, allowing the cached-path query to request _path directly
instead of deriving it with strings.Replace. Preserve the existing target-type
handling, arguments, and no-row behavior for both source-path and cached-path
callers.
- Around line 80-97: Define shared constants or sentinel errors for the
local-image failure messages currently matched by isStableProviderImageFailure,
and update image_cache_processor.go to emit those shared values instead of
duplicating string literals. Update the classifier to match the shared symbols
while preserving the existing stable-failure categories and retry behavior.

In `@migrations/sql/20260712100125_builtin_host_providers.sql`:
- Around line 15-21: Keep the non-concurrent index and column DDL in this
migration unchanged, since plugin_installations is a small control-plane table;
do not add CREATE/DROP INDEX CONCURRENTLY without restructuring goose
transaction handling. Apply the same decision to the corresponding
down-migration statements for idx_plugin_installations_builtin_plugin_id and the
dropped kind column.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cbb05d36-2e5a-4550-88f4-21dfbd5fb380

📥 Commits

Reviewing files that changed from the base of the PR and between 28c6ddc and 1663aec.

📒 Files selected for processing (60)
  • cmd/silo/main.go
  • docs/architecture/local-nfo-metadata.md
  • docs/architecture/v1-scope.md
  • docs/wiki/admin/media-folder-and-naming.md
  • docs/wiki/admin/nfo-local-metadata.md
  • docs/wiki/index.md
  • internal/api/handlers/libraries.go
  • internal/api/handlers/plugins.go
  • internal/api/handlers/plugins_builtin_test.go
  • internal/catalog/folder_repo.go
  • internal/catalog/folder_repo_local_roots_test.go
  • internal/catalog/item_repo.go
  • internal/catalog/local_image_paths_test.go
  • internal/imagecache/imagecache.go
  • internal/imagecache/local_key_test.go
  • internal/metadata/builtin.go
  • internal/metadata/builtin_sync.go
  • internal/metadata/builtin_test.go
  • internal/metadata/canonicalize.go
  • internal/metadata/chain.go
  • internal/metadata/chain_builtin_db_test.go
  • internal/metadata/export_nfo_test.go
  • internal/metadata/image_cache_job_repo.go
  • internal/metadata/image_cache_job_repo_test.go
  • internal/metadata/image_cache_processor.go
  • internal/metadata/image_cache_processor_local_test.go
  • internal/metadata/local_artwork_db_test.go
  • internal/metadata/local_image_source_test.go
  • internal/metadata/match_candidates.go
  • internal/metadata/match_candidates_defang_test.go
  • internal/metadata/match_candidates_test.go
  • internal/metadata/merge.go
  • internal/metadata/nfo/builtin_registration_test.go
  • internal/metadata/nfo/images.go
  • internal/metadata/nfo/images_test.go
  • internal/metadata/nfo/nfo.go
  • internal/metadata/nfo/nfo_test.go
  • internal/metadata/nfo/provider.go
  • internal/metadata/nfo/provider_test.go
  • internal/metadata/nfo/register.go
  • internal/metadata/nfo/series_depth.go
  • internal/metadata/nfo/series_depth_test.go
  • internal/metadata/nfo_identity_test.go
  • internal/metadata/nfo_merge_semantics_test.go
  • internal/metadata/nfo_mixed_library_test.go
  • internal/metadata/nfo_series_depth_test.go
  • internal/metadata/service.go
  • internal/metadata/types.go
  • internal/plugins/auto_update.go
  • internal/plugins/builtin_guard_test.go
  • internal/plugins/event_dispatcher.go
  • internal/plugins/installation.go
  • internal/plugins/manifest.go
  • internal/plugins/service.go
  • internal/plugins/task_registry.go
  • migrations/sql/20260712100125_builtin_host_providers.sql
  • migrations/sql/20260712124741_nfo_capability_season_episode_levels.sql
  • web/src/components/EditMetadataDialog.tsx
  • web/src/components/admin/libraries/LibraryForm.test.tsx
  • web/src/components/admin/libraries/useLibraryForm.ts
💤 Files with no reviewable changes (1)
  • internal/metadata/image_cache_job_repo_test.go

Comment thread internal/plugins/installation.go Resolved
Fold in the valid, low-risk fixes surfaced by automated review on #390:

- imagecache: extract validateCacheRequest so CacheBytes (the local
  sidecar season/episode path) enforces the same episode-requires-season
  guard as Cache, preventing distinct episodes' art from colliding under
  one S3 key.
- image_cache_processor: close the sidecar symlink-swap window by
  rejecting the opened handle unless os.SameFile matches the Lstat'd
  file, so a leaf swapped to a symlink can't pull an out-of-root target
  into the public cache.
- plugins: guard the reserved builtin installation row in the store's
  Update, matching Delete, so its version/enabled/capabilities can never
  be rewritten even if a mutation slips past the HTTP layer.
- cmd/silo: bound SyncBuiltinProviderChains with a 30s timeout so a stuck
  DB round-trip fails fast at startup instead of hanging.
- metadata: panic instead of silently no-op'ing on an invalid
  RegisterBuiltinProvider call (init-time programmer error).
- docs: correct the media-folder-and-naming NFO paragraph to state
  season/episode NFOs and sidecar artwork are actively read.
@CoffeeKnyte

Copy link
Copy Markdown
Contributor Author

Processed the review. Pushed 82cc5ab with the valid, low-risk fixes; dispositions for the remaining review-body items below.

Fixed

  • imagecache.go — CacheBytes was missing the episode-requires-season guard Cache has. Extracted a shared validateCacheRequest used by both, so the local sidecar season/episode path can no longer collide distinct episodes under one S3 key and the two paths cannot drift again. (covers both the outside-diff finding and the duplicate-validation nitpick)
  • cmd/silo/main.go — SyncBuiltinProviderChains now runs under a bounded 30s context so a stuck DB round-trip fails fast at startup.
  • internal/metadata/builtin.go — RegisterBuiltinProvider now panics on an empty id / nil constructor instead of silently no-opping; registration is init-time only, so this is a loud programmer-error guard.
  • internal/plugins/installation.go — builtin-row guard added to Update (see inline reply).
  • docs — NFO paragraph corrected (see inline reply).

Deferred (follow-up)

  • Requeue local artwork when the path is unchanged (Codex) — see inline reply; needs a scoped local-vs-remote ON CONFLICT change.
  • Extend TestBuiltinInstallationMutationsRejected to the other guarded handlers — worth doing, but the HTTP-layer guards are already in place and exercised for delete/update; broadening the table is a test-only follow-up.

Skipped (deliberate)

  • Parameterize the _source_path→_path column suffix instead of strings.Replace — the current query has exactly one occurrence and is covered by tests; refactor churn without a live bug. Noted for if that query grows a second _source_path column.
  • Hoist local-failure strings into shared constants — real coupling, but a pure refactor touching both files; leaving as a follow-up to keep this commit focused on correctness.
  • Migration CONCURRENTLY note — no action needed; plugin_installations is a small control-plane table and the reviewer agreed non-concurrent DDL is fine here.

Verification: go build ./..., go vet, and go test ./internal/imagecache/... ./internal/metadata/... ./internal/plugins/... all green; gofmt clean.

@dreulavelle

Copy link
Copy Markdown

Any progress on this lately 👀

@Quick104
Quick104 merged commit 91e1164 into main Jul 16, 2026
@Quick104
Quick104 deleted the feat/local-metadata-nfo branch July 16, 2026 21:55

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7756ab7716

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1783 to +1785
if !isNew && req.Mode == ModeManualRefresh && contentid.IsProviderAnchored(contentID) {
reanchored, err := s.reanchorContentID(
ctx, contentID, providerIDsStruct(accumulator.ProviderIDs), contentType)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Recompose child IDs when reanchoring a series

When a manual refresh accepts a corrected NFO ID for an established series, this renames the series but leaves its existing season and episode content_id values embedding the old provider anchor. The FK cascade updates episodes.series_id, but internal/catalog/history_source.go derives the owning series directly from the episode ID, so history and other identity-based flows continue targeting the now-missing old series. Recompose the child IDs as part of the same reanchor operation before enabling this path for populated series.

Useful? React with 👍 / 👎.

query.ProviderIDs["_filepath"],
)
return findNFO(candidatePaths)
_, parsed := findNFO(candidatePaths, query.ContentType)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Gate folder-level NFOs on single-content roots

When multiple movies are stored directly in one folder, candidatePaths still contains each media file even though PrimarySidecarSearchPaths is intentionally empty for a multi-content root. findNFO expands every such file to the sibling movie.nfo before trying its basename-specific NFO, so one shared movie.nfo supplies the same trusted provider ID to every movie and can deduplicate unrelated items into one catalog entry. Directory-level NFO candidates should only be derived from the already-validated sidecar search paths; media-file paths should contribute only <basename>.nfo.

Useful? React with 👍 / 👎.

Comment on lines +312 to +313
if nfoDatePattern.MatchString(c) {
return c

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate NFO dates as real calendar dates

When an NFO contains a date-shaped but invalid value such as 2024-13-40, this regex accepts it and the value reaches the PostgreSQL date columns through ItemRepository.Upsert, causing the entire match or refresh to fail with an invalid-date error. Validate candidates with time.Parse("2006-01-02", c) rather than checking only their shape so one malformed sidecar field cannot block all metadata updates for the item.

Useful? React with 👍 / 👎.

Comment thread cmd/silo/main.go
Comment on lines +1166 to +1170
syncCtx, syncCancel := context.WithTimeout(appCtx, 30*time.Second)
syncErr := metadata.SyncBuiltinProviderChains(syncCtx, chainRepo)
syncCancel()
if syncErr != nil {
log.Fatalf("sync builtin provider chains: %v", syncErr)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make the startup builtin-chain sync set-based

On installations with many existing libraries, this mandatory 30-second startup step can prevent the server from booting: SyncBuiltinProviderChains calls AppendProviderToAllChains, which performs a capability-metadata lookup and membership query for every folder/level pair, plus max-priority and insert queries for missing rows. The same N+1 scan runs on every restart even after all rows exist, and any timeout is fatal here. Use a set-based INSERT ... SELECT ... ON CONFLICT operation or move the repair out of the fatal startup path.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1.0 Silo v1 scope - auto-adds to the Silo v1 project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants