Skip to content

fix(core): reject taxonomy and menu translations under a different name - #3101

Open
danielmlr wants to merge 1 commit into
emdash-cms:mainfrom
danielmlr:fix/translation-source-name
Open

fix(core): reject taxonomy and menu translations under a different name#3101
danielmlr wants to merge 1 commit into
emdash-cms:mainfrom
danielmlr:fix/translation-source-name

Conversation

@danielmlr

Copy link
Copy Markdown
Contributor

What does this PR do?

Rejects a taxonomy or menu translation created under a different name than its source. Creating either with translationOf accepted any name, so the new row joined the source's translation group under a second name. Both resolve by name and locale, so a lookup by the source's name in that locale never returned the translation.

The create handlers now return VALIDATION_ERROR when the names differ. The REST routes and the MCP taxonomy_create and menu_create tools use them; the menu translations route already passes the source's name. Explicit hierarchical and collections on a taxonomy translation still apply as given, and seed application is unchanged.

Part of #2525

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. (n/a: no admin UI change)
  • 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/... (n/a: bug fix)
  • I have included screenshots below if this PR changes the UI (n/a: no UI change)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 5

Screenshots / test output

Not applicable for screenshots.

  • The new taxonomy and menu cases fail on main and pass here on SQLite; CI also runs the taxonomy case on Postgres.
  • pnpm test in packages/core → 553 test files passed, 2 skipped; 6788 tests passed, 10 skipped

Creating a taxonomy or a menu with `translationOf` accepted any `name`,
so the new row could join the source's translation group under a second
name. Both are looked up by name and locale, so the source's name never
returned that translation in its locale.

The two create handlers now return VALIDATION_ERROR when the names differ.
The REST routes and the MCP `taxonomy_create` and `menu_create` tools go
through them; the menu translations route already passes the source's
name.
@changeset-bot

changeset-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6187ea5

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

This PR includes changesets to release 18 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/plugin-test 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 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/auth-atproto

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

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

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

emdash

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

create-emdash

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

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

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

@emdash-cms/plugin-cli

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

@emdash-cms/plugin-test

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

@emdash-cms/plugin-types

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

@emdash-cms/registry-client

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

@emdash-cms/registry-lexicons

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

@emdash-cms/registry-moderation

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

@emdash-cms/registry-verification

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

@emdash-cms/sandbox-workerd

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-field-kit

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 6187ea5

@danielmlr
danielmlr marked this pull request as ready for review September 13, 2026 18:36
@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Sep 13, 2026

@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 translation-name issue described in #2525. Menus and taxonomy definitions are resolved by (name, locale), so a translation created under a different name joins the source's translation group but is invisible to lookups that use the source name. Rejecting the mismatch at the create handlers is the correct place: both the REST POST routes and the MCP taxonomy_create/menu_create tools call these handlers, and the dedicated menu translations route already passes the source's name.

The implementation is small and safe: the name check runs after the source-existence check and before any duplicate guard or DB write, so a mismatched-name request returns VALIDATION_ERROR without persisting anything. The input schemas and the repository layer remain unchanged except for the new validation, which is fine because the handlers are the API boundary. The new tests verify the actual failure (wrong name → VALIDATION_ERROR plus no row created) rather than asserting the implementation back at itself, and existing translation-success tests still pass with matching names. The changeset accurately describes the user-facing behavior.

I checked the changed handlers, the menu translation route, the MCP tool definitions, the input schemas, the repository implementations, and the updated tests. No logic bugs, no authorization/locale-filter/SQL issues, and nothing on the logged-out hot path. The only optional improvement would be surfacing the name-must-match constraint in the MCP tool descriptions and the OpenAPI taxonomy translations description, but that's a documentation completeness note, not a blocker.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core review/approved Approved; no new commits since size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant