fix(translator): tier-C config guards (localization enqueue, field exclude, duplicate level) - #85
Merged
Conversation
A manual /enqueue with localization disabled or absent kept every requested
target locale and passed it to payload.update({ locale }) — orphaning rows
(Mongo/SQLite), erroring on a Postgres locale enum, or, with no localization
at all, overwriting the single unlocalized field and wiping the source.
Guard the handler to 400 before enqueuing, and drop the null branch from
resolveTargetLocales so a localization-less config is unrepresentable.
…ation route
The /field route resolved a path by field type only, so a field opted out via
withFieldTranslation({ exclude }) could still be translated by naming its path
directly — bypassing the opt-out the whole-document path honors via
isTranslatableLeaf. resolveFieldSubtree now returns a distinct `excluded`
status for such a leaf (uniformly, including inside blocks), and the handler
no-ops it with a clear notice instead of translating.
…clared twice A level listed twice (e.g. levels: [documentLevel(), documentLevel()]) attached its admin control to each managed collection twice, rendering a duplicated button. Endpoints already dedup by (method, path); attachCollectionComponents now mirrors that, deduping by (slot + component path) so a duplicate level renders one control silently.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🎉 This PR is included in version 0.10.2 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three independent correctness fixes for the translator plugin, all from the
config-combination-rules plan (
docs/plans/2026-07-29-config-combination-rules.md,tier "real defects" + duplicated-control). Each is a separate commit → three
distinct changelog entries under one patch release.
Fixes
1. Reject manual enqueue when localization is disabled (D2)
A manual
POST /translate/enqueuewith localization disabled or absent keptevery requested target locale and passed it to
payload.update({ locale })—orphaning rows (Mongo/SQLite), erroring on a Postgres locale enum, or, with no
localization at all, overwriting the single unlocalized field and wiping the
source. The handler now returns
400before enqueuing anything, andresolveTargetLocalesno longer accepts anulllocale set, so alocalization-less config is unrepresentable.
2. Honor field-level exclude on the single-field translation route (D1)
The
/fieldroute resolved a path by field type only, so a field opted outvia
withFieldTranslation({ exclude })could still be translated by naming itspath directly — bypassing the opt-out the whole-document path honors via
isTranslatableLeaf.resolveFieldSubtreenow returns a distinctexcludedstatus for such a leaf (uniformly, including inside blocks) and the handler
no-ops it with a clear notice.
3. De-duplicate translation controls when a level is declared twice (X1)
A level listed twice (e.g.
levels: [documentLevel(), documentLevel()])attached its admin control to each managed collection twice, rendering a
duplicated button. Endpoints already dedup by
(method, path);attachCollectionComponentsnow mirrors that, deduping by(slot + component path)so a duplicate level renders one control silently.Verification
dist.tscdeclaration build succeeds.Notes / out of scope
/fieldroute also does not checklocalized(a non-localized fieldcould be translated by naming its path). Same class as feature/payload plugin comments #2 but a separate
concern — left as a follow-up, not folded in.
unknown-drop / de-dup) into one shared unit shared by the auto-translate and
manual paths is the planned next slice; kept out here to keep the diff tight.