Skip to content

Fixed lazy URL service wrongly disowning posts in collection routes#29008

Draft
allouis wants to merge 1 commit into
mainfrom
lazy-url-collection-post-ownership
Draft

Fixed lazy URL service wrongly disowning posts in collection routes#29008
allouis wants to merge 1 commit into
mainfrom
lazy-url-collection-post-ownership

Conversation

@allouis

@allouis allouis commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

ref https://linear.app/ghost/issue/HKG-1875

Summary

In compare mode the lazy URL service reported ownsResource as false for posts that the eager service owned, surfacing as LAZY_URL_PARITY_MISMATCH divergences.

The collection controller hands each rendered post to ownsResource to drop posts that a higher-priority collection actually owns (so the same post never renders on two collection URLs). The lazy service decides ownership by evaluating the base filter status:published+type:post against the resource — but the Content API serializer strips both status and type from public posts, so the filter never matched and every candidate post was disowned and removed from the collection.

The eager service is unaffected: it owns by cache id membership (hasId), with the base filter applied once at fetch time against full models, so it never re-evaluates the filter per call.

Fix

The controller already restored type; this restores status: 'published' as well, which is always correct because collections only ever load published posts (postsPublic). Restoring the stripped column keeps the base filter fully enforced rather than relaxing it, preserving parity with eager.

Testing

TDD: added a controller unit test that simulates a Content-API-stripped post (no type/status) and asserts the resource handed to ownsResource carries both restored. Confirmed it fails before the fix and passes after. Full collection.test.js suite green; lint clean.

ref https://linear.app/ghost/issue/HKG-1875

- in compare mode the lazy URL service reported ownsResource false for
  posts the eager service owned, surfacing as LAZY_URL_PARITY_MISMATCH
- the collection controller hands each rendered post to ownsResource to
  drop posts a higher-priority collection owns; the lazy service decides
  ownership by evaluating the base filter status:published+type:post
  against the resource, but the Content API serializer strips both
  status and type from public posts, so the filter never matched and
  every candidate post was disowned and removed from the collection
- the eager service is unaffected: it owns by cache id membership
  (hasId), with the base filter applied once at fetch against full
  models, so it never re-evaluates the filter per call
- the controller already restored type; restore status: 'published' as
  well, which is always correct because collections only ever load
  published posts. Restoring the stripped column keeps the base filter
  fully enforced rather than relaxing it, preserving parity with eager
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 242a8435-158c-4b24-b785-b1b2c6b5cd1a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lazy-url-collection-post-ownership

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 6ce674e

Command Status Duration Result
nx run ghost:test:ci:integration ✅ Succeeded 2m 36s View ↗
nx run ghost:test:integration ✅ Succeeded 2m 50s View ↗
nx run ghost:test:legacy ✅ Succeeded 3m 2s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 28s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗
nx run-many -t lint -p ghost ✅ Succeeded 35s View ↗
nx run-many -t test:unit -p ghost ✅ Succeeded 29s View ↗
nx run @tryghost/admin:build ✅ Succeeded 8s View ↗
Additional runs (2) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-01 08:04:10 UTC

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