Skip to content

Comments

fix(cli): use separator-bounded matching for key pattern filters#2010

Merged
AndreyHirsa merged 6 commits intomainfrom
fix/exact-key-matching
Feb 23, 2026
Merged

fix(cli): use separator-bounded matching for key pattern filters#2010
AndreyHirsa merged 6 commits intomainfrom
fix/exact-key-matching

Conversation

@AndreyHirsa
Copy link
Contributor

@AndreyHirsa AndreyHirsa commented Feb 23, 2026

Summary

Fix key pattern matching to use separator-bounded comparison instead of substring prefix matching, preventing lockedKeys, ignoredKeys, preservedKeys, and localizableKeys from incorrectly matching unrelated keys that share a prefix.

Changes

  • Replace key.startsWith(pattern) with exact match (key === pattern) plus separator-bounded prefix checks (key.startsWith(pattern + "."), key.startsWith(pattern + "/") and key.startsWith(pattern + "-")) in matchesKeyPattern.
  • Add tests covering exact match, separator-bounded match, and no-match for non-separator prefixes (e.g., inbox vs inbox_url)

Testing

Business logic tests added:

  • Exact key match
  • No match for keys sharing prefix without separator
  • Match for dot-separated children
  • Match for slash-separated children
  • Match for dash-separated children
  • All existing tests pass
  • E2E verified with JSON demo

Visuals

N/A - no UI changes.

Checklist

  • Changeset added
  • Tests cover business logic (not just happy path)
  • No breaking changes

Summary by CodeRabbit

  • Bug Fixes

    • Improved CLI key matching so keys match only on exact equality or when the pattern is followed by a separator (".", "/", or "-"), avoiding false positives from shared prefixes while preserving glob behavior.
  • Tests

    • Expanded tests covering exact matches, separator-bounded matches, separator rejection cases, and existing glob patterns.
  • Chores

    • Added a changelog entry documenting the patch.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ddb8114 and 9195b8f.

📒 Files selected for processing (2)
  • packages/cli/src/cli/utils/key-matching.spec.ts
  • packages/cli/src/cli/utils/key-matching.ts

📝 Walkthrough

Walkthrough

Switches CLI key matching from substring prefix matching to exact matches and separator-bounded prefixes (separators: ".", "/", "-"), while retaining glob-pattern support; adds tests and a changelog entry documenting the fix.

Changes

Cohort / File(s) Summary
Key Matching Implementation & Tests
packages/cli/src/cli/utils/key-matching.ts, packages/cli/src/cli/utils/key-matching.spec.ts
Replaced substring prefix logic with exact-match and separator-bounded prefix checks (supports ".", "/", "-"); preserved existing glob matching. Expanded tests for exact matches, rejection of non-separator-prefixed keys (e.g., inbox_url), and separator cases like inbox.title, inbox/details, heading-0.
Changelog Entry
.changeset/flat-beans-wonder.md
Added patch release note describing the key matching behavior change for lingo.cli.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibbled through keys, precise and spry,
Dots, slashes, dashes now let true names fly.
Exactness hops in, no more stray confound—
A tidy match, and carrots all around! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: switching from prefix matching to separator-bounded matching for key pattern filters in the CLI.
Description check ✅ Passed The description covers all required sections: Summary explains the fix, Changes detail the implementation, Testing lists all test cases, Visuals correctly notes N/A, and Checklist confirms all items are complete.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/exact-key-matching

Comment @coderabbitai help to get the list of available commands and usage tips.

@AndreyHirsa AndreyHirsa merged commit bd71fd3 into main Feb 23, 2026
9 checks passed
@AndreyHirsa AndreyHirsa deleted the fix/exact-key-matching branch February 23, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants