Skip to content

[Routine - VT] fix(core): don't throw on a malformed file:// URI when matching stored file entries - #112

Draft
winterdrive wants to merge 1 commit into
mainfrom
routine/vt-fix-fileentrymatcher-malformed-uri-260806
Draft

[Routine - VT] fix(core): don't throw on a malformed file:// URI when matching stored file entries#112
winterdrive wants to merge 1 commit into
mainfrom
routine/vt-fix-fileentrymatcher-malformed-uri-260806

Conversation

@winterdrive

Copy link
Copy Markdown
Owner

1. Pre-flight Check

Open PRs/branches checked (via gh pr list --state open and gh pr diff <n> --name-only):

PR Files touched
#111 src/core/GroupManager.ts, src/test/unit/groupManagerNonArrayConfig.test.ts
#110 dependabot deps bump
#109 src/mcp/SkillGenerator.ts
#108 src/dragAndDrop.ts, src/test/unit/dragIsDescendantCycleGuard.test.ts
#107 src/core/AutoGrouper.ts, src/test/unit/autoGrouperBookmarks.test.ts
#106 i18n/*.json, src/provider.ts
#105 src/commands.ts, src/i18n.ts, src/test/unit/copyGroupName.test.ts
#104 mcp-server/src/server.ts

This PR only touches src/core/FileEntryMatcher.ts and its test file, which do not appear in any open PR's diff, so there is no overlap.

2. Changes

matchesStoredFileEntry() (used by FileManager.addFilesToGroup/removeFilesFromGroup, BookmarkManager.createBookmark, and GroupFileRemoval) called fileURLToPath() directly on a stored file:// entry with no try/catch. A malformed URI — e.g. a hand-edited/corrupted config entry with an unescaped % such as a file literally named 100%.ts — makes fileURLToPath throw "URI malformed", which propagated up and aborted the entire add/remove/bookmark operation for every file in the call, not just the offending entry.

BookmarkManager.normalizeFileKey already guards the equivalent call with a try/catch. This PR applies the same defensive pattern to FileEntryMatcher.toComparableFsPath: on a malformed URI it now returns undefined (treated as "does not match") instead of throwing.

Added a regression test (fileEntryMatcher.test.ts) asserting matchesStoredFileEntry does not throw and returns false for a malformed file:// stored entry.

This PR does not modify any command registrations, contributed configuration keys (package.json), dependencies, or the tab-group serialization/storage format. It is a pure defensive-coding fix in a single pure function.

3. Safety Verification

Commands run locally, all passed:

npx tsc -p ./
npm run test

Output: tsc produced no errors; jest --runInBandTest Suites: 31 passed, 31 total, Tests: 204 passed, 204 total (203 pre-existing + 1 new).

No lint or format:check script exists in package.json, so those steps were skipped.

4. CI / Release Gate Note

This is a daily routine Draft PR. Package version bump (package.json/package-lock.json) and CHANGELOG.md updates are intentionally deferred to the weekend release/integration PR. If CI fails solely due to the repository's version-bump/release gate, that is expected release-readiness behavior for a routine PR, not a code validation failure.

🤖 Generated with Claude Code

…d file entries

matchesStoredFileEntry() called fileURLToPath() directly without a try/catch,
so a hand-edited or corrupted config entry with an unescaped '%' (e.g. a file
named "100%.ts") would throw "URI malformed" and abort the whole
addFilesToGroup/removeFilesFromGroup/createBookmark/group-file-removal
operation for every file, not just the bad entry. BookmarkManager already
guards the equivalent fileURLToPath() call; FileEntryMatcher now does the
same, treating a malformed entry as non-matching instead of crashing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

routine Daily automated maintenance PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant