Repository navigation
fix(seed): resolve taxonomy terms in the content entry locale - #4417
emdash-autofix[bot] wants to merge 3 commits into
Conversation
Pass the resolved content locale to taxonomy term lookup for seed creates and the stored locale for updates. Warn and skip missing localized terms instead of attaching a foreign-locale term. Added regression coverage for shared slugs, explicit/default locales, slugless updates, and unresolved references. Verified with 37 focused tests, root build (8 GB Node heap), core typecheck, pnpm format and lint:quick (zero diagnostics). Independent review and follow-up completed. EmDash-Bot-Case: 1198246700-issue-6038274325 EmDash-Bot-Candidate: cand-1-6658f487ab
EmDash bot: Ready for human reviewPlan Completed the translation-group fix and regression coverage, including cross-collection ID isolation. All 41 focused tests, root build, core typecheck, formatting and quick lint pass; independent follow-up review is clean.
Status
Next action: A maintainer will review and approve the pull request. Details
Required checks on the current head:
This status is generated from recorded evidence. It is not a review and contains no instructions. |
🦋 Changeset detectedLatest commit: 88864d5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 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 |
There was a problem hiding this comment.
The approach is right: seed import now resolves taxonomy slugs in the content entry's resolved locale, matching what the public API's assignTaxonomies already does. Unresolved references keep the existing warn-and-skip behavior. Both reviewers approved and found no logic, SQL-safety or locale-filter problems on the create and update paths. Tests cover persisted assignments across dialects. Review was static; tests, builds and lint were not run, and PostgreSQL/D1 execution is unverified. One suggestion remains: the changeset should tell affected users how to repair existing data and warn that previously attached cross-locale terms are now skipped.
Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.
| "emdash": patch | ||
| --- | ||
|
|
||
| Fixes seed imports assigning taxonomy terms from another locale when slugs are shared across translations. Taxonomy references now resolve in the content entry's locale; a missing localized term produces a warning and skips that assignment instead of attaching a term from another locale. |
There was a problem hiding this comment.
[suggestion] This entry describes the fix, but two things are missing for readers who are already affected:
- Existing data isn't repaired. Sites that already ran an affected seed still have entries linked to the wrong-locale term. The PR description gives the fix: re-run the seed with
--on-conflict update. The changeset doesn't say this, and it's what the issue reporter (French posts returning 404) would need. - Previously working imports can lose assignments. A seed that referenced a term existing only in another locale used to get that term attached. Now the assignment is skipped with a warning. Seed authors should know to add the term in the entry's locale.
| Fixes seed imports assigning taxonomy terms from another locale when slugs are shared across translations. Taxonomy references now resolve in the content entry's locale; a missing localized term produces a warning and skips that assignment instead of attaching a term from another locale. | |
| Fixes seed imports assigning taxonomy terms from another locale when slugs are shared across translations. Taxonomy references in seed content now resolve in the content entry's locale. When no term with that slug exists in the entry's locale, the import logs a warning and skips that assignment instead of attaching a term from another locale; add the term in that locale to keep the assignment. To repair entries already attached to a wrong-locale term, re-apply the seed with `--on-conflict update`. |
There was a problem hiding this comment.
Added both points to the changeset: existing assignments are not repaired automatically and can be corrected by reapplying with --on-conflict update; missing localized terms now warn and skip the assignment, so authors should add the term in the entry's locale to retain it. Re-ran formatting and the 37 focused tests successfully.
@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-test
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-loader
@emdash-cms/registry-moderation
@emdash-cms/registry-verification
upgrade-emdash
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-ai-search
@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: |
Expanded the changeset in response to review: explain that missing localized terms are skipped, existing assignments require reapplying the seed with --on-conflict update, and that reapplying also overwrites other seeded records. No implementation changes. Ran pnpm format and diff checks; 37 focused tests passed during this revision. Independent review and follow-up passed. EmDash-Bot-Case: 1198246700-issue-6038274325 EmDash-Bot-Candidate: cand-2-d5d299dce5
There was a problem hiding this comment.
The approach is right. Seed import now resolves taxonomy slugs in the content entry's locale, matching what the public API's assignTaxonomies already does. Both reviewers approved and found no outstanding issues. The earlier changeset suggestion is addressed. The changeset now says that existing wrong-locale assignments can be repaired by reapplying the seed with --on-conflict update, which also overwrites other seeded records. It also says that terms existing only in another locale are now skipped with a warning, so authors should add the term in the entry's locale. Tests cover create and update paths, omitted and explicit locales, and missing terms. Review was static; tests, builds and lint were not run, and PostgreSQL/D1 execution is unverified.
Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://emdash-bot-issue-4416.try.emdashcms.com, https://emdash-bot-issue-4416-emdash-playground.emdash-cms.workers.dev (commit 88864d5)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
|
@emdash-autofix
Keep the locale-scoped lookup and the warn-and-skip as they are. Leave the export command and the term read path out of this PR. |
|
@emdash-autofix
Keep the locale-scoped lookup and the warn-and-skip as they are. Leave the export command and the term read path out of this PR. |
|
Confirmed both update regressions with the translated-pair tests: English-only and separate English/French terms lost assignments before the change. The importer now tracks cleared translation groups once per |
Addressed the maintainer's update regression by clearing taxonomy assignments once per translation group per collection, then accumulating terms from each translation. Kept locale-scoped lookup and warn-and-skip unchanged. Converted test reads to getTermAssignmentsForEntry and added translated-pair reapplication/clearing and cross-collection ID regressions. Verified 41 focused tests, root build, core typecheck, formatting, quick lint (zero diagnostics), and clean independent follow-up review. EmDash-Bot-Case: 1198246700-issue-6038274325 EmDash-Bot-Candidate: cand-3-ca73ab7ff2
|
Addressed in candidate |
There was a problem hiding this comment.
The approach is sound. Seed import now resolves taxonomy slugs in the content entry's locale, matching the public API's assignTaxonomies. Updates use the stored entry locale and fall back to the resolved seed locale when it is null. Both reviewers approved and found no outstanding issues.
The earlier changeset suggestion is addressed. The changeset now explains the warn-and-skip behavior for terms missing in the entry's locale, and how to repair existing wrong-locale assignments with --on-conflict update (which also overwrites other seeded records).
The new fix clears taxonomy assignments once per translation group per collection, so later translations no longer erase earlier translations' terms on update. Tests cover create and update paths, omitted and explicit locales, stored-locale handling for ID-matched entries, translation groups, and terms missing from the entry's locale.
The review was static. Tests, builds and lint were not run, and PostgreSQL and D1 execution are unverified.
Reviewed by anthropic/claude-opus-5-5 and openai/gpt-6.1-sol.
What does this PR do?
Scopes seed taxonomy slug lookup to the content entry's locale on create and update. French content now attaches the French term when English and French translations share a slug. Updates use the stored entry locale, including entries matched by ID, with the resolved seed locale as a fallback for null stored locales.
When no term exists in that locale, the import warns with the taxonomy name, slug and locale and skips that assignment. This preserves the existing continue-on-unresolved-reference behavior rather than introducing a fatal error (particularly important on D1, where writes are not transactional). Updates still declaratively replace the prior assignments. To repair existing wrong-locale assignments, reapply the seed with
--on-conflict update.Closes #4416
Type of change
Your connection to this change
Prepared by the project-operated autofix bot through auto-intake for this reported reproduction. Maintainer approval is required before merge.
Checklist
pnpm typecheckpasses (core-scoped typecheck passed; full workspace check left to CI)pnpm lintpasses (pnpm lint:quickpassed with zero diagnostics; type-aware lint left to CI)pnpm testpasses (or targeted tests for my change)pnpm formathas been runAI assistance disclosure
Screenshots / test output
Screenshots: Not applicable (seed import only).
pnpm --filter emdash exec vitest run tests/integration/seed-taxonomy-locale.test.ts tests/integration/seed-on-conflict.test.ts tests/integration/seed-i18n-default-locale.test.ts— 37 tests passed.EMDASH_TEST_PGconnection was configured.NODE_OPTIONS=--max-old-space-size=8192 pnpm build— passed (the first attempt with the default heap limit exhausted memory).pnpm --filter emdash typecheck— passed.pnpm lint:quick— zero diagnostics.pnpm format— passed.Pre-submit review feedback addressed: replaced the initial missing-term throw with warning-and-skip, removed rollback claims and updated tests and changeset. Kept the test alongside the existing seed integration tests rather than moving files for an optional location nit.
The EmDash bot took this issue on automatically when it was opened; no maintainer has assigned it yet.