Repository navigation
fix: preserve revisionless content on publish - #2460
Conversation
🦋 Changeset detectedLatest commit: a9f0056 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
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 |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | a9f0056 | Aug 13 2026, 04:09 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | a9f0056 | Aug 13 2026, 04:09 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-do | a9f0056 | Aug 13 2026, 04:11 PM |
There was a problem hiding this comment.
This PR fixes the right bug in the right place. Publishing for collections that don't support revisions was syncing data from a stale live_revision_id into the content columns, overwriting edits made via direct column updates. The change makes ContentRepository.publish() accept a promoteRevision flag and, when false, perform a lifecycle-only UPDATE (status → published, clear scheduled_at, set published_at/updated_at, bump version) without touching field columns or live/draft revision pointers. The handler determines the collection's revision support from _emdash_collections.supports and passes the flag accordingly, so revision-enabled collections continue to promote drafts normally.
I checked the full diff and supporting code: the new branch is SQL-safe (uses sql.ref for identifiers and parameterized values), preserves optimistic-concurrency and scheduled-due fences, re-stamps the taxonomy pivot and invalidates the collection cache the same way the promote path does, and reuses the existing reconciliation helpers. The regression test in drafts.test.ts reproduces the stale-revision scenario and asserts the current column data survives publish. The changeset is user-facing and concise. There are no new logged-out queries, no admin UI strings requiring localization, and no new indexes needed.
The code is clean; I found no blocking issues.
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
Pull request overview
Fixes a data-loss bug where publishing entries in collections that don’t support revisions could overwrite current column data with stale data from live_revision_id. The change introduces a “lifecycle-only” publish path for revisionless collections, while keeping the existing revision-promotion behavior for revision-enabled collections.
Changes:
- Add a
promoteRevisionoption toContentRepository.publish()to support lifecycle-only publishing (no column sync). - Update
handleContentPublish()to decide whether to promote a revision based on collection supports. - Add an integration regression test reproducing “stale live revision overwrites fresh columns” for a non-revision collection, plus a changeset entry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/core/tests/integration/mcp/drafts.test.ts | Adds regression coverage for publishing on non-revision collections when live_revision_id is stale. |
| packages/core/src/database/repositories/content.ts | Implements lifecycle-only publish path via promoteRevision flag and reconciliation helper. |
| packages/core/src/api/handlers/content.ts | Detects whether a collection supports revisions and passes that into repo.publish(). |
| .changeset/calm-pandas-publish.md | Patch changeset describing the bug fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
This is a re-review: my previous approval stands and there are no new blocking issues.
Approach judgment: The fix is the right change in the right place. Publishing should not overwrite current content-table values with stale revision data for collections that don't support revisions. Adding a promoteRevision flag to ContentRepository.publish() and driving it from the handler's check of _emdash_collections.supports keeps the repository generic while fixing the API/MCP/scheduled-publish entry points in one place. The default promoteRevision = true preserves backward compatibility for all existing callers.
What I re-checked:
- SQL safety: The new lifecycle-only branch uses
sql.ref()for the dynamic table name andnullableColumnMatch()(which validates identifiers) for nullable lifecycle columns; all values are parameterized. No string interpolation into SQL. - Concurrency/correctness: The lifecycle-only UPDATE keeps the same optimistic-concurrency fence (
version,status,live_revision_id,draft_revision_id,scheduled_at) as the promote path, bumpsversion, preservespublished_atwhen no override is supplied, clears staledraft_revision_id, and only creates a provisional live revision when none exists. It also reuses the existing reconciliation helper and provisional-revision cleanup logic. - Cross-cutting paths:
scheduled-publish.tsandEmDashRuntime.handleContentPublishboth route throughhandleContentPublish, so they inherit the lifecycle-only behavior automatically.seed/apply.tsstill callspublish()with the defaultpromoteRevision = true; it remains safe because seed data is self-consistent (the draft revision created before publish carries the same data as the updated columns). - Tests: The added regression tests in
drafts.test.tscover first publish, an unexpected stale draft pointer, and a stalelive_revision_id— all observable outcomes, not implementation-detail tautologies. - AGENTS.md conventions: Changeset is present and user-facing; no new logged-out queries; no admin UI strings requiring Lingui/RTL work; no new indexes required.
No findings to report; the PR is clean.
…ublish (#2466) * fix(core): remove stale restampEntryPivot call that crashes content publish The merge of #2460 and #2461 left main with a publish path that calls restampEntryPivot, a method #2461 deleted together with the pivot denormalization it maintained. Every content publish now throws "this.restampEntryPivot is not a function". No replacement call is needed: since migration 068 the pivot columns the call re-stamped are legacy, and reads join the authoritative ec_* row. * chore: add changeset for the publish crash fix The fix changes the published emdash package, and release notes are built from changeset files, so the crash fix needs an entry even though the crash itself never shipped in a release.
What does this PR do?
Prevents publishing a collection without
revisionssupport from replacing current content-table values with stale data fromlive_revision_id. Revisionless publishing now updates lifecycle metadata only, while revision-enabled collections continue promoting the staged draft revision normally.Closes #2095
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI-generated code disclosure
Screenshots / test output
Not applicable; this is a non-visual data-layer fix.
Validation:
pnpm lint:json | jq '.diagnostics | length'—0pnpm lint:quickpnpm lintpnpm typecheckpnpm --filter emdash exec vitest run tests/integration/mcp/drafts.test.ts tests/unit/database/repositories/content.test.ts tests/unit/scheduled-publish.test.ts tests/integration/seed-live-revisions.test.ts— 98 tests passed