Skip to content

fix(core): skip slug-change redirects without a URL pattern - #4337

Open
emdash-autofix[bot] wants to merge 1 commit into
mainfrom
emdash-bot/issue-4334
Open

emdash-autofix[bot] wants to merge 1 commit into
mainfrom
emdash-bot/issue-4334

Conversation

@emdash-autofix

Copy link
Copy Markdown
Contributor

What does this PR do?

Skips automatic slug-change redirects when a collection's URL pattern is NULL or empty. Previously, the URL interpolation fallback invented /{collection}/{slug} redirect paths even when the site served entries through custom Astro routes. The shared repository now returns null before acquiring the redirect write lock or changing any redirect rules, so both direct updates and staged slug publishes treat the redirect as not created.

This deliberately stops automatic redirects for NULL-pattern collections, including sites that really serve the fallback paths. To preserve those redirects, set an explicit matching URL pattern, such as /posts/{slug}. The changeset and SEO guide explain this upgrade action and the difference from sitemap/menu fallbacks. The empty-string case already produced no redirect; tests retain coverage for it.

Adds regressions for both publish paths, no-pattern repository calls, and preservation of manual rules. Configured URL patterns remain authoritative: this does not infer custom nested routes or fix a configured pattern that differs from the site's routing. Trailing-slash handling (#3437) is unchanged. No migration removes existing incorrect redirects; sites with custom routing must manage redirects for their real public URLs. Existing publish-time cleanup of auto rules shadowing a fallback path is unchanged.

Closes #4334

Type of change

  • Bug fix
  • Feature (requires an accepted feature plan or RFC)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Your connection to this change

Project-operated autofix bot working on the reported bug through auto-intake, under the AI policy's autofix exception. Maintainer approval is required before merge.

  • I use EmDash and ran into the problem this PR addresses
  • I maintain a tool, dependency, or service that EmDash uses, and this change concerns that integration
  • A Maintainer approved this specific change before I opened the PR

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (not applicable: no new UI strings)
  • I have added and reviewed the user-facing changeset
  • New features link to their merged design PR (not applicable: bug fix)
  • I have included screenshots below if this PR changes the UI (not applicable: no UI rendering changes)

AI assistance disclosure

  • This PR includes AI-generated code or text — model/tool: cloudflare-ai-gateway:gpt-6.1-sol via the EmDash bot (Pi Durable)

Screenshots / test output

Screenshots: Not applicable; no UI rendering changes.

Passed:

  • pnpm build
  • pnpm --filter emdash exec vitest run tests/integration/redirects tests/unit/api/content-handlers.test.ts
  • pnpm --filter emdash typecheck
  • pnpm lint:quick (zero diagnostics)
  • pnpm format
  • pnpm --dir docs build
  • git diff --check

The new NULL-pattern repository tests failed before the fix by returning /posts/old-slug → /posts/new-slug. Tests pass with the guard. Direct-update tests use the dialect wrapper; SQLite ran locally, PostgreSQL was not configured. Full workspace typecheck and type-aware lint are left to CI.

The EmDash bot took this issue on automatically when it was opened; no maintainer has assigned it yet.

Return null before redirect writes when the collection URL pattern is NULL or empty, preventing guessed fallback redirects for both direct slug updates and staged publishes. Added repository and handler regressions, a patch changeset, and SEO documentation including the upgrade action for sites relying on fallback URLs. Verified root build, focused redirect/content tests, core typecheck, quick lint (zero diagnostics), formatting, docs build, and whitespace checks. Independent review and follow-up completed without outstanding findings.

EmDash-Bot-Case: 1198246700-issue-5972562856
EmDash-Bot-Candidate: cand-1-11e0f8a029
@emdash-autofix emdash-autofix Bot added the bot:fix Assign this issue or pull request to the EmDash bot to fix label Oct 22, 2026
@emdash-autofix

emdash-autofix Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

EmDash bot: Changes required

Plan

Implementation and focused verification are complete, but review identified a release-policy blocker: a maintainer must decide how to handle existing sites relying on NULL-pattern fallback redirects.

  • Read redirect creation paths and existing tests
  • Skip automatic redirects without an explicit URL pattern and cover publish paths
  • Run focused checks and independent review
  • (blocked) Obtain maintainer compatibility and release decision

Status

  • The review bot requested changes on the current head.

Next action: The bot will respond to the review.

Details
Candidate cand-1-11e0f8a029 (tree b681de42e489)
Published head 8ee30a9b5370
Reviewer's latest review of head changes_requested, 2 item(s)
Reporter confirmation confirmed
Human approval required before merge

Required checks on the current head:

  • Typecheck: succeeded
  • Tests: succeeded
  • Smoke Tests: succeeded
  • Browser Tests: succeeded
  • Format: succeeded
  • CLAssistant: succeeded
  • Measure: succeeded

This status is generated from recorded evidence. It is not a review and contains no instructions.

@changeset-bot

changeset-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8ee30a9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/plugin-test Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
create-emdash Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://emdash-bot-issue-4334.try.emdashcms.com, https://emdash-bot-issue-4334-emdash-playground.emdash-cms.workers.dev (commit 8ee30a9)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://f0a91f4a.try.emdashcms.com, https://f0a91f4a-emdash-playground.emdash-cms.workers.dev 8ee30a9 2026-10-22T03:51:45.174Z Visit the dashboard ↗

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
docs 8ee30a9 Oct 22 2026, 03:50 AM

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

The approach is sound: guarding createAutoRedirect in the shared repository, before the write lock, stops invented /{collection}/{slug} redirects. It covers both the direct slug edit and the staged _slug publish, and it leaves manual rules alone. Reviewers agreed there are no implementation defects, and the new tests cover both paths with real databases. They disagreed on the verdict. One approved with no findings. The other requested changes because the change silently alters default behavior for existing sites that serve the fallback URLs, and it ships as a patch without the maintainer sign-off that AGENTS.md and the changeset README require. Because one reviewer raised a blocking finding, the verdict is request_changes.


Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.

oldPublishedAt?: string | null,
newPublishedAt?: string | null,
): Promise<Redirect | null> {
if (!urlPattern) return null;

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.

[needs fixing] This also disables working behavior for existing collections with a NULL pattern that actually serve /{collection}/{slug}. After upgrading, renaming a published entry from b to c leaves /posts/b returning 404, and an existing /posts/a → /posts/b rule is no longer collapsed. The previous fallback regression test covered this supported behavior, and the changeset acknowledges that users must change their configuration to keep it.

AGENTS.md requires an explicit compatibility decision and a major release for breaking changes on 1.x. .changeset/README.md also requires prior maintainer approval for significant default changes. The PR context says that approval is still outstanding, yet this ships as "emdash": patch. Get the maintainer's compatibility decision and release strategy before shipping, or provide a compatibility-preserving way to opt custom-routed collections out. Documenting the workaround alone does not satisfy the policy.

The other reviewer (claude-opus-5-5) did not flag this as blocking. It noted the behavior change and the maintainer sign-off requirement but approved, since the changeset gives a concrete migration (set /posts/{slug} explicitly) and the PR description calls out the need for sign-off.

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.

Agreed that the migration note does not supply release approval. The same NULL value currently represents both sites using the fallback paths and sites with unknown custom routes, so this guard cannot distinguish them. It fixes the reported guessed redirects but also stops working redirect creation and chain collapse for the former group.

I’m requesting a maintainer decision on whether to approve the explicit-pattern requirement and its release strategy, or retain fallback behavior and pursue a compatibility-preserving opt-out. I won’t change the release classification or add a new configuration API without that decision.

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/admin@4337

@emdash-cms/auth

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/auth@4337

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/auth-atproto@4337

@emdash-cms/blocks

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/blocks@4337

@emdash-cms/cloudflare

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/cloudflare@4337

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/contentful-to-portable-text@4337

emdash

npm i https://pkg.pr.new/emdash-cms/emdash@4337

create-emdash

npm i https://pkg.pr.new/emdash-cms/emdash/create-emdash@4337

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/gutenberg-to-portable-text@4337

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-cli@4337

@emdash-cms/plugin-test

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-test@4337

@emdash-cms/plugin-types

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-types@4337

@emdash-cms/registry-client

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-client@4337

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-lexicons@4337

@emdash-cms/registry-loader

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-loader@4337

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-moderation@4337

@emdash-cms/registry-verification

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-verification@4337

upgrade-emdash

npm i https://pkg.pr.new/emdash-cms/emdash/upgrade-emdash@4337

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/sandbox-workerd@4337

@emdash-cms/x402

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/x402@4337

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-ai-moderation@4337

@emdash-cms/plugin-ai-search

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-ai-search@4337

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-atproto@4337

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-audit-log@4337

@emdash-cms/plugin-color

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-color@4337

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-embeds@4337

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-field-kit@4337

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-forms@4337

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-webhook-notifier@4337

commit: 8ee30a9

@emdash-autofix emdash-autofix Bot added the triage/verified Reporter verified the fix label Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core area/docs bot:fix Assign this issue or pull request to the EmDash bot to fix cla: signed size/M triage/verified Reporter verified the fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slug-change auto-redirect is created for collections without a URL pattern, using paths that don't exist

0 participants