docs(node): document that sync config readers require initializeGT - #471
Open
moss-bryophyta wants to merge 1 commit into
Open
docs(node): document that sync config readers require initializeGT#471moss-bryophyta wants to merge 1 commit into
initializeGT#471moss-bryophyta wants to merge 1 commit into
Conversation
getDefaultLocale, getLocales, getRequestLocale, and getVersionId all throw when called before initializeGT, but their reference pages described them only as synchronous config readers. getVersionId's page went further and said it returns undefined when no version ID is configured, which is true only after initialization. Verified against installed gt-node@1.0.15.
moss-bryophyta
enabled auto-merge (squash)
August 17, 2026 20:24
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
Four
gt-nodereference pages describe synchronous configuration readers without mentioning that they throw when called beforeinitializeGT.initialize-gt.mdxalready documents this precondition, but names only the translation functions (withGT,getGT,getMessages), so these four look exempt.get-version-id.mdxhad the sharper problem: it statedgetVersionId"returnsundefinedwhen no version ID is configured." That is true only after initialization. Before it, the call throws — so a reader following the documented?? nullexample on a cold path gets an exception instead of a null.Verification
Runtime-checked against installed
gt-node@1.0.15(current published version), not the changelog:And after
initializeGT({ defaultLocale: 'en', locales: ['en','fr'] })with no version ID set:So the documented
string | undefinedreturn is correct, and the missing piece is the precondition.getLocaleis intentionally not changed — it throws for a different reason (the request-scoped condition store) and its page already documents thewithGTscope requirement accurately.Changes
Requires initializationbullet toget-default-locale,get-locales,get-request-locale, andget-version-id, matching the existing house phrasing inwith-gt.mdx("must be called before X is used, or an error is thrown").get-request-locale's note, which softened a hard throw into "so it knows which locales are supported."get-version-id'sundefinedclaim to post-initialization.initialize-gt.mdxnote to name the four readers.Checks
All 5 validators pass: unsafe-html 450, callouts 450, reference-links 404/256 aliases, structure valid, links all valid.
Found during a routine audit of the
nodedocs against the published package.