Conversation
DiscoveringFileSystemTranslationSource discards the middle filename segment, so files like Foo.A.en-US.i18n.json and Foo.B.en-US.i18n.json resolve to the same (namespace, locale). AddOrUpdateNamespace then silently overwrote the first with the last-loaded file, with no diagnostic - a consumer with a missing/empty discovery prefix (or a duplicate prefix-less registration) silently served the wrong file. Retain the file path per TranslationSet and log an error when a different file overwrites an already-loaded namespace for a locale. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
DiscoveringFileSystemTranslationSourcediscovers files named<Namespace>.<discriminator>.<locale>.i18n.json, butFileSystemTranslationSourceBase's filename regex discards the middle segment(s). SoFoo.A.en-US.i18n.jsonandFoo.B.en-US.i18n.jsonboth resolve to namespaceFoo, localeen-US.TranslationData.AddOrUpdateNamespacethen silently replaces the first with the last-loaded file (last-wins), with no warning and without even retaining the file paths.Impact
Any consumer that discovers multiple files for one namespace — e.g. a
DiscoveringFileSystemTranslationSourcewithprefix == null, or a caller that registersAddDefaultLocalization()a second time without a prefix — silently serves whichever file loads last. This is invisible whenever the colliding files have identical content, so it only surfaces once they diverge. We hit exactly this in a service that used per-subdivision files (Foo.Maestra.en-US/Foo.Mindbox.en-US): aMaestra-configured service silently served theMindboxstrings.Change
TranslationSetnow retains its sourceFilePath.AddOrUpdateNamespacelogs an error when a different file overwrites an already-loaded namespace for a locale, naming both files and pointing at the likely cause (a missing discoveryprefix). Reloading the same file path stays silent.Chosen
LogErrorover throwing so it is non-breaking for existing consumers while making the misconfiguration immediately diagnosable; a strict/throw opt-in could be a follow-up.Tests
Added
FileSystemTranslationSourceCollisionTests:prefixthat isolates one file → no error.Full suite passes (24 tests).