mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
fix(i18n): stop one key template from whitelisting a whole namespace
The reverse-coverage guard asserts that every key in the bundle is reachable from a call site. It had stopped doing that for most of the bundle. A template whose only static anchor was a namespace root registered that root as a subtree base, so a single per-provider OAuth key marked every key under `settings.*` reachable, and the same shape did it for `measurementReminders.*`. A cache-key string that happens to start with a namespace word had quietly done it for `insights.*` too. The guard stayed green throughout, which is the part worth noticing: a pair guard degrades into a one-end guard without any signal. Extract the matcher into a helper with its own unit tests, and change what it accepts. A template carrying both a literal prefix and a literal suffix now records the pair and requires both ends to match, so the OAuth template covers the provider keys and nothing else. A template with no suffix whose anchor is a bare namespace no longer whitelists anything — it fails the guard by name, with the two honest remedies in the message. The same door is used by the template, assignment and concatenation arms, so none of them can reopen it. Template bodies are read by scanning forward from a known opening backtick rather than by pairing backticks across the tree, which was drifting and dropping whole files out of the scan. Three call sites build their keys whole instead of interpolating onto a namespace root: the two measurement-reminder due helpers, the mental-health option labels, and the OAuth error copy, which now names its per-provider base. Two audit-log action names that merely look like keys carry a written exemption; the API error catalog is a runtime lookup and is allowlisted with its reason. With the matcher honest, 149 keys had no call site left. They belong to an explainer popover, a hypnogram, a passkey table and an insights hero that were all rebuilt or removed, and they are deleted from all six locales. The explainer guard stops pinning its title leaves, which no surface has rendered since the popover went.
This commit is contained in:
1 parent
f9a5e6a11f
commit
d8a3c08e12
17 files changed
+680
-1155
No files matched your search
@@ -93,6 +93,23 @@ const OAUTH_OUTCOME_KEYS: Record<
|
||||
strava: queryKeys.strava,
|
||||
};
|
||||
|
||||
/**
|
||||
* v1.32.36 — the error-copy subtree per provider, spelled out rather than
|
||||
* interpolated from the provider id. Building the key from the bare `settings`
|
||||
* root left the reverse-i18n guard with no anchor deeper than the namespace,
|
||||
* which marked every key under `settings.*` reachable and let genuinely dead
|
||||
* copy sit in the bundle unnoticed. Written out, each base is a full node path
|
||||
* the guard resolves on its own.
|
||||
*/
|
||||
const OAUTH_ERROR_KEY_BASE: Record<OAuthOutcomeProvider, string> = {
|
||||
polar: "settings.polarOauthError",
|
||||
oura: "settings.ouraOauthError",
|
||||
whoop: "settings.whoopOauthError",
|
||||
fitbit: "settings.fitbitOauthError",
|
||||
googleHealth: "settings.googleHealthOauthError",
|
||||
strava: "settings.stravaOauthError",
|
||||
};
|
||||
|
||||
/**
|
||||
* Reason tags the four OAuth callbacks emit. Known tags resolve to a specific
|
||||
* message; anything else falls back to the provider's `generic` copy. Union of
|
||||
@@ -143,9 +160,10 @@ export function oauthReasonKey(
|
||||
provider: OAuthOutcomeProvider,
|
||||
reason: string,
|
||||
): string {
|
||||
const base = OAUTH_ERROR_KEY_BASE[provider];
|
||||
return OAUTH_OUTCOME_REASONS.has(reason)
|
||||
? `settings.${provider}OauthError.${reason}`
|
||||
: `settings.${provider}OauthError.generic`;
|
||||
? `${base}.${reason}`
|
||||
: `${base}.generic`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user