fix(desktop): validate locale:set input against supported locales#97
Merged
fix(desktop): validate locale:set input against supported locales#97
Conversation
`locale:set` previously accepted any non-empty string and persisted it to ~/.config/open-codesign/locale.json. A bad write (whether from a renderer bug or third-party caller) was silently rewritten to "en" at read time by normalizeLocale, masking the underlying problem and leaving users on the wrong language until they manually cleared the file. Reject unsupported tags up-front, canonicalize aliases (zh-Hans-CN → zh-CN) before persisting, and cover the new behavior with tests for rejection, canonicalization, and bad input shapes.
Contributor
There was a problem hiding this comment.
Findings
- No issues found in added/modified lines with high confidence.
Summary
- Review mode: initial
- No blocker/major/minor/nit findings in the latest diff.
docs/VISION.mdanddocs/PRINCIPLES.md: Not found in repo/docs in this checkout, so that context could not be revalidated here.- Residual risk: no test in this diff verifies renderer/UI error surfacing when
locale:setrejects invalid locales.
Testing
- Not run (automation)
open-codesign 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.
Summary
locale:setIPC accepted any non-empty string and persisted it to~/.config/open-codesign/locale.json.normalizeLocalethen silently rewrote bad values toenat read time, masking the underlying bug and stranding users on the wrong language until they cleared the file.zh-Hans-CN→zh-CN) before persisting, and add tests for rejection, canonicalization, and bad input shapes.Constraint check (PRINCIPLES §5b)
{schemaVersion: 1, locale}unchanged; we just stop writing garbage intolocale.@open-codesign/i18nexports; no new deps.Test plan
pnpm --filter @open-codesign/desktop test -- src/main/locale-ipc.test.ts(4/4 pass)pnpm --filter @open-codesign/desktop typecheckpnpm exec biome check apps/desktop/src/main/locale-ipc.ts apps/desktop/src/main/locale-ipc.test.ts