Repository navigation
fix(cli): make run --key match real keys and stop it poisoning i18n.lock - #2197
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 6 minutes Limit details: You’ve used all 3 included reviews currently available. Your 40 included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour. You’re in a promotional period — use the checkbox below to run this review for free:
On-demand reviews are free for the next 31 days. After that, they cost $0.25 per reviewed file. How can I continue?Run this review now using the option above, or comment You can also wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour. 📝 WalkthroughWalkthroughThe CLI now applies flat-key matching semantics to ChangesCLI key filtering
Estimated code review effort: 2 (Simple) | ~15 minutes Merge Risk: 🟠 High · up to A 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Update after a structured review: five lenses in parallel, then every load-bearing finding handed to a separate agent whose job was to refute it. Two findings that looked like blockers did not survive that; two real ones did and are fixed in Fixed after review
Live end-to-end confirmation: with all three source strings edited, The help text promised globs that match nothing. The guard returned after the work was already done. Comment and test cleanup. The guard comment stated the
Refuted, and worth recordingA Untranslated source text leaking into target files under Known gaps, deliberately not in this PR
Not verified: anything at the scale of the reported case. The end-to-end runs used small fixtures, so the mechanism is confirmed and the volume is not. |
Fixes ENG-1419. Two defects in
run --keythat have to ship together.Both surfaced in this week's feedback triage. Two users reported the symptom as "
--forcedoes not compose with--key", which is the wrong reading.--forcecomposes fine.--keyis what breaks.1.
--keymatched nothingcomputeProcessableDatafiltered with a rawminimatchcall, but flat buckets flatten nested keys with/. The example in the CLI's own help was--key auth.login, which matches zero keys. The task's processable set came out empty, the run skipped it, and the output read as a success: "4 from cache, 0 processed".The intended semantics were already in the repo.
matchesKeyPattern(packages/cli/src/cli/utils/key-matching.ts) does exact, separator-bounded prefix, and glob matching, and is whatshowand the locked/ignored/preserved filters use. It just was not wired intorun --key.Measured on the keys a flat bucket actually produces:
Only prefix matching changes. Globs and exact keys behaved correctly before and still do.
auth/login_urlstays out, because a prefix has to stop at a separator.The last row is why the help text changed:
auth.loginnever matched anything and still does not. The help now documents/, states that prefixes stop at a separator, and gives an example that works.2. A filtered run overwrote unrelated lockfile entries
persistChecksumswrote checksums for every source key, not just the translated subset, anddelta.tsreplaces the whole section. So a--keyrun marked the untouched majority as translated. In the reported case, 837 changed keys with a filter over 10 of them would have marked the other 827 as done for good.The guard already existed for
--target-locale. It now covers--keytoo.These ship together on purpose: while
--keymatches nothing, the write is unreachable. Fixing the matcher alone is what would first make the data loss reachable.Verification
Four tests, written before the fix. The prefix-matching one failed; globs and exact keys passed already and are kept as regression guards. The lockfile guard test failed without the change.
Also run end to end against the live API with a real project:
--key auth/login. Only the twologinkeys were retranslated.auth/logout/titlekept the translation from step 1 rather than picking up its new source text, confirming it was filtered rather than silently translated. The lockfile was byte-identical to before.auth/logout/titleandsettings/profile/name, which is what proves the lockfile was not poisoned. Had it been, those keys would have counted as translated and never been retried.packages/clisuite: 953 passed. One unrelated failure,lockfile.spec.ts, is abeforeEachtimeout under parallel load; the file passes on its own in 3.9s against a 10s hook budget and references nothing this PR touches. Typecheck clean.Known gap, not fixed here
frozen.tswrites checksums for all source keys when a project has no lockfile yet, and that path does not go throughpersistChecksums, so the guard above does not reach it. A--keyrun on a project without a lockfile therefore still marks every key as translated. Found while verifying against a real project rather than from reading the code. Same defect class as point 2, one line to fix, deliberately left out of this PR rather than folded in silently.Not verified: anything at the scale of the reported case. The end-to-end run used a four-key fixture, so the mechanism is confirmed and the volume is not.
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
run --keymatching for exact keys, separator-aware prefixes, nested paths, and glob patterns.Documentation
--keyhelp text with supported slash-separated paths, prefix rules, and recursive glob examples.