Skip to content

fix(catalog): reject disabled dual-library items - #43

Merged
blurbery merged 3 commits into
mainfrom
fix/catalog-disabled-library-dual-membership
Aug 24, 2026
Merged

blurbery merged 3 commits into
mainfrom
fix/catalog-disabled-library-dual-membership

Conversation

@blurbery

@blurbery blurbery commented Aug 23, 2026 •

Copy link
Copy Markdown
Owner

Problem

Related issue: N/A — narrow fix

Disabled-library filtering was evaluated against one joined membership row. An item linked to both an enabled library and a disabled library could therefore pass through its enabled row. The same membership join could also duplicate POST catalog rows and inflate COUNT(*) OVER() totals.

The current fork and upstream implementations of the affected starting paths were byte-identical before this change.

Approach

  • Enforce enabled membership and disabled membership as independent item-level EXISTS / NOT EXISTS predicates.
  • Preserve a positive membership requirement for disabled-only viewers so orphaned items do not become visible through a vacuous anti-join.
  • Remove membership fanout from POST catalog, facet, recommendation, and Jellyfin compatibility lookups while retaining the indexed single-library browse path.
  • Preserve the global disabled-library deny through recently-added fanout and request-scoped catalog library resolution.
  • Route section episode hydration through the same parent-series membership policy, removing its membership join and closing the direct FetchEpisodesByContentIDs gap.
  • Require current episode_libraries membership on the optimized episode-entry scan before applying its global deny.
  • Apply the same invariant to the bounded set of reachable catalog, episode-catalog, compatibility, recommendation, and recently-added query paths found by the production-code search.
  • Add SQL-plan regressions plus the existing database fixture's dual-membership browse, facet, and recently-added assertions.

Validation

Red against 13d2dcd72fb8b7c4e109766c533e4b2c19c9c9ad before the production change:

go test ./internal/catalog -run 'Test(BuildBrowsePlanDisabled|FilterWhereClauseDisabled)' -count=1
FAIL — all three new assertions exposed the row-local deny / membership join

Passing after the fix:

go test ./internal/catalog -count=1
go test ./internal/access -count=1
go test ./internal/api/handlers -count=1
go test ./internal/sections -count=1
go test ./internal/recommendations -count=1
go test ./internal/jellycompat -run 'Test(ApplyCompatLibraryAccess|FetchCompat.*Fallback)' -count=1
go build ./internal/catalog ./internal/api/handlers ./internal/jellycompat ./internal/recommendations ./internal/sections
go vet ./internal/catalog ./internal/api/handlers ./internal/jellycompat ./internal/recommendations ./internal/sections
make verify-local-paths

The database-backed TestDualLibraryItemDeniedByDisabledLibraryDB was discovered and compiled but skipped locally because SILO_TEST_DATABASE_URL is unset. The complete local internal/jellycompat package run reached two pre-existing macOS process-identity failures (TestBeginWebOperationRecoversDeadProcessLock and TestBeginWebOperationRejectsLiveProcessLock); all changed Jellycompat tests pass. GitHub Actions remains the full-matrix authority.

GitHub Actions on 4670728deaf7b8199a764d9aee0fe4029b35e3c1 passed the complete Go, Web, and docs-hygiene jobs. An earlier run stopped at changed-lines lint because the new recently_added comparison crossed the goconst threshold; 6b5e55b0 extracted the package constant, and the replacement run passed lint and full Go tests.

No UI files changed, so screenshots are not applicable.

Risks

No migration or production configuration change. The policy change is deliberately fail-closed for dual-membership items: any membership in a disabled library hides the item, even when another requested or allowed membership exists. The correlated membership probes use existing membership primary/index keys; the reviewed paths either remove join fanout or retain their indexed single-library fast path.

AI Disclosure

  • Tool(s): OpenAI Codex
  • Model(s): GPT-5
  • Involvement: AI-assisted
  • Adversarial review: Two independent full-diff reviews checked access-control composition, SQL placeholder ordering, uniqueness/count semantics, membership-index usage, episode scoping, and reachable sibling paths. The correctness review found that request-scoped catalog libraries erased the global disabled list; the resolver was fixed, regression-tested, and re-reviewed clean. A subsequent review found that section episode hydration still ignored the disabled scope; it was moved onto the canonical parent-series membership predicates, given disabled-only and allowed-plus-disabled regressions, and re-reviewed clean. The SQL/performance reviews found no material blocker.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

@blurbery
blurbery merged commit a6b86f1 into main Aug 24, 2026
3 checks passed
@blurbery
blurbery deleted the fix/catalog-disabled-library-dual-membership 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant