Skip to content

fix(core): respect seeded collections for default taxonomies - #3025

Closed
scottbuscemi wants to merge 1 commit into
mainfrom
fix/seed-default-taxonomy-collections
Closed

scottbuscemi wants to merge 1 commit into
mainfrom
fix/seed-default-taxonomy-collections

Conversation

@scottbuscemi

Copy link
Copy Markdown
Contributor

What does this PR do?

Allows a site's initial seed to replace the untouched built-in category and tag taxonomy definitions created by migrations. This ensures templates and custom sites can associate those taxonomies with collections other than posts, so taxonomy filtering returns the seeded collection's content.

Normal onConflict: "skip" behavior is preserved after a built-in definition has been configured.

Reported directly; no issue.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

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 (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/... (not applicable: bug fix)
  • I have included screenshots below if this PR changes the UI (not applicable: no UI changes)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: OpenCode with GPT-5.6-sol

Screenshots / test output

Not applicable; no UI changes.

pnpm --filter emdash exec vitest run tests/integration/seed-on-conflict.test.ts (23 tests passed)

@changeset-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7d8fc6f

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

This PR includes changesets to release 17 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site 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/release-service 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

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/auth-atproto

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

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

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

emdash

npm i https://pkg.pr.new/emdash@3025

create-emdash

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

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

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

@emdash-cms/plugin-cli

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

@emdash-cms/plugin-types

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

@emdash-cms/registry-client

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

@emdash-cms/registry-lexicons

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

@emdash-cms/registry-moderation

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

@emdash-cms/registry-verification

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

@emdash-cms/sandbox-workerd

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-field-kit

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 7d8fc6f

@github-actions github-actions Bot added review/needs-review No maintainer or bot review yet area/core size/M labels Sep 10, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-seed-default-taxonomy-collections.try.emdashcms.com, https://fix-seed-default-taxonomy-collections-emdash-playground.emdash-cms.workers.dev (commit 7d8fc6f)

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://aaecdbc2.try.emdashcms.com, https://aaecdbc2-emdash-playground.emdash-cms.workers.dev 7d8fc6f 2026-09-10T15:56:19.480Z Visit the dashboard ↗

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

This is the right fix for the reported problem: with onConflict: "skip" (the default), EmDash was never updating the factory category and tag taxonomy definitions, so templates and custom sites that associate those taxonomies with collections other than posts ended up with empty taxonomy filters. The change narrowly targets those untouched built-in rows and preserves normal skip behavior once a definition has been deliberately configured.

What I checked:

  • packages/core/src/database/migrations/006_taxonomy_defs.ts creates the built-in category and tag definitions with exactly the IDs, labels, hierarchy flags, and collections value the new heuristic expects.
  • apply.ts now updates only when the existing row is still the untouched factory default (isUntouchedBuiltInTaxonomy) and only in skip/update paths; onConflict: "error" still throws as before.
  • The integration test covers both category and tag, verifies the initial override, and verifies that a second seed with the factory defaults is skipped (i.e., the definition is now "configured").
  • The changeset is user-facing and proportional for a patch.
  • No logged-out hot-path changes, no SQL injection surface, no missing locale filters, no Lingui/RTL/UI concerns.

I did not find any blocking bugs. One maintainability note: the factory-default values are duplicated between migration 006_taxonomy_defs.ts and the new heuristic in apply.ts. That is flagged as a suggestion.

/** Pattern to collapse multiple hyphens */
const MULTIPLE_HYPHENS_PATTERN = /-+/g;

function isUntouchedBuiltInTaxonomy(definition: {

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.

[suggestion] This function duplicates the factory defaults already defined in packages/core/src/database/migrations/006_taxonomy_defs.ts (ids, labels, hierarchical, and the `[

@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-review No maintainer or bot review yet labels Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been inactive for 14 days. It will be closed automatically in 7 days if there is no further activity.

If you're still working on this, please push an update or leave a comment.

@ascorbic

Copy link
Copy Markdown
Member

Superseded by #3355, which implements seeded replacement of untouched built-in taxonomies with the fuller accounting, options, documentation, and tests.

@ascorbic ascorbic closed this Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core needs-rebase review/awaiting-author Reviewed; waiting on the author to respond size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants