Skip to content

Fix locale-scoped content updates#1302

Merged
ascorbic merged 3 commits into
emdash-cms:mainfrom
WellDunDun:WellDunDun/vienna-v1
Jun 3, 2026
Merged

Fix locale-scoped content updates#1302
ascorbic merged 3 commits into
emdash-cms:mainfrom
WellDunDun:WellDunDun/vienna-v1

Conversation

@WellDunDun
Copy link
Copy Markdown
Contributor

@WellDunDun WellDunDun commented Jun 2, 2026

What does this PR do?

Fixes locale-scoped content updates when callers update by slug and multiple locales share that slug.

This wires locale through REST PUT /content/:collection/:id?locale=..., the core handler/runtime slug resolution, the JS client, CLI content update, and MCP content_update. The CLI also uses the returned concrete item.id for follow-up publish/refetch calls so it does not reuse an ambiguous slug after a locale-scoped update.

Closes #1243

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 a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: N/A, bug fix

AI-generated code disclosure

  • This PR includes AI-generated code - model/tool: Codex (GPT-5-5 xHigh)

Screenshots / test output

Non-visual bug fix.

Checks run:

  • pnpm build
  • pnpm lint:quick
  • pnpm typecheck
  • pnpm lint
  • pnpm --filter emdash test tests/unit/api/content-handlers.test.ts tests/unit/api/content-route-permissions.test.ts tests/unit/client/client.test.ts tests/unit/mcp/authorization.test.ts tests/integration/mcp/content-misc.test.ts
  • pnpm --filter emdash test:integration tests/integration/cli/cli.test.ts
  • pnpm format
  • git diff --check

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 2, 2026

🦋 Changeset detected

Latest commit: da551f2

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

This PR includes changesets to release 14 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/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash 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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown
Contributor

@emdashbot emdashbot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a solid, well-scoped bug fix. The approach — threading an optional locale through slug resolution so updates target the right row when multiple locales share a slug — is exactly what #1243 calls for, and it fits EmDash's architecture (locale is already optional in findByIdOrSlug, handleContentGet, etc.).

I checked the full diff and traced the locale parameter:

  • REST route ([id].ts): extracts locale from query params, passes it to handleContentGet for ownership lookup and into the handleContentUpdate body. Correct.
  • Handler (content.ts): resolveId now forwards locale to the repository. Correct.
  • Runtime (emdash-runtime.ts): uses locale for the initial slug→ID resolution and passes it through to the handler. Correct.
  • JS client: appends locale as a query param on the PUT URL. Correct.
  • CLI: exposes --locale, passes it through, and importantly switches follow-up publish/get calls to use the resolved concrete updated.id instead of the ambiguous slug. Good defensive fix.
  • MCP server: adds locale to the content_update input schema and forwards it. Correct.
  • Tests: handler, route-permission, client, CLI integration, and MCP integration tests all cover the locale-scoped update scenario. Good coverage.

No logic bugs, security issues, or AGENTS.md violations found. The parameterized Kysely queries in findBySlug are safe, the change is additive/backwards-compatible, and the changeset is present.

One small gap: the OpenAPI document (packages/core/src/api/openapi/document.ts) does not declare the locale query parameter on the updateContent PUT operation. The GET operation on the same path already documents it; the PUT spec should match so API consumers know the parameter exists.

Comment thread packages/core/src/astro/routes/api/content/[collection]/[id].ts
@WellDunDun
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@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 Jun 2, 2026
Co-authored-by: emdashbot[bot] <273199577+emdashbot[bot]@users.noreply.github.com>
@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review and removed review/awaiting-author Reviewed; waiting on the author to respond labels Jun 2, 2026
Copy link
Copy Markdown
Collaborator

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 3, 2026

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/auth-atproto

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

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

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

emdash

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

create-emdash

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

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

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

@emdash-cms/plugin-cli

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

@emdash-cms/plugin-types

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

@emdash-cms/registry-client

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

@emdash-cms/registry-lexicons

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

@emdash-cms/sandbox-workerd

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-field-kit

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: da551f2

@ascorbic ascorbic merged commit 1f8190d into emdash-cms:main Jun 3, 2026
36 checks passed
@emdashbot emdashbot Bot mentioned this pull request Jun 3, 2026
ascorbic added a commit that referenced this pull request Jun 3, 2026
Main's #1302 already added locale reading to the PUT content-update
route. Drop this branch's duplicate declaration (kept main's
request.url form, which the existing route test exercises) so the
merged PUT handler has a single `locale`. The branch's remaining core
contribution is locale on DELETE and the publish/unpublish/schedule/
discard-draft sub-action routes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI content update should support --locale for slug resolution

2 participants