Fix public route and entity resolution invariants - #587
Merged
Conversation
- Add documented catch-all route grammar with pure resolvers; all non-matching paths (e.g. /unknown/about, 3+ segments) now 404 - Preserve slugOverrides hooks in slugField so ensureUniqueSlug runs - Pass the resolved entity object to blocks; promise-list blocks no longer re-resolve entities by slug without tenant scoping - Deliberately disable pagination on the main promise list instead of silently truncating at Payload's default page size - Add branded (frontend) not-found and error pages - Add migration verifying no duplicate per-tenant entity slugs - Add route-matrix, slug-uniqueness, and pagination tests Closes #574 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #574
What changed
Route grammar & 404s
[...slugs]catch-all grammar (tenant:/,/:entitySlug,/:entitySlug/:pageSlug,/:pageSlug; global:/and/:pageSlugonly).notFound()for every non-matching path./unknown(no matching entity or page),/unknown/about, and 3+ segment paths return real 404s instead of silently rendering the entity selector.Entity resolution
slugFieldoverwritingslugOverrides.hooks, which silently disabled theensureUniqueSlugbeforeValidate hook on political entities — per-tenant slug uniqueness is now actually enforced.(tenant, slug)pairs exist.BlockRenderernow passes the route-resolved entity object to blocks;promise-listandlatest-promisesblocks use it directly instead of re-resolving by slug without tenant scoping (previously a cross-tenant slug collision could resolve the wrong entity). Their fallback slug lookup is now tenant-scoped.Promise lists
limit, so Payload silently capped it at 10 records. It now deliberately requests all published promises (pagination: false) via a shared, tested query builder; the teaser list keeps its explicitlimit: 3.Branded error handling
(frontend)/not-found.tsxand(frontend)/error.tsx(Sentry-instrumented) so 404s/500s get branded pages while preserving HTTP semantics vianotFound().Migrations
migrations/20260720_000000_check_political_entity_slug_uniqueness.ts— verification only; throws with a list of duplicates if any exist, no data changes.Tests
tests/int/publicRoutes.int.spec.ts— route matrix: tenant, global, entity, duplicate-slug, and invalid paths.tests/int/politicalEntitySlugs.int.spec.ts— slug field keeps the uniqueness hook; hook rejects duplicates per tenant.tests/int/promiseListQuery.int.spec.ts— pagination behavior of the promise list query.tsc --noEmitclean.🤖 Generated with Claude Code