fix(backend): decode percent-encoded characters in generic git URL config - #1607
fix(backend): decode percent-encoded characters in generic git URL config#1607Harsh23Kashyap wants to merge 1 commit into
Conversation
…nfig `compileGenericGitHostConfig_url` in `packages/backend/src/repoCompileUtils.ts` derived the repo `name` / `displayName` / zoekt metadata from `remoteUrl.pathname` without decoding percent-encoded characters. The file-origin counterpart (`compileGenericGitHostConfig_file`) already calls `decodeURIComponent` on the origin URL pathname, so the same remote configured as a direct URL vs. discovered from a local repository origin ended up with two different identifiers. Concretely, a URL like `https://github.com/test/Project%20Name%20With%20Spaces.git` and a file config pointing at the same remote would derive: - direct URL: `github.com/test/Project%20Name%20With%20Spaces` - file origin: `github.com/test/Project Name With Spaces` That breaks search-index metadata (the value is written into `zoekt.name` / `zoekt.display-name` / `name` / `displayName`) and makes the same repository look like two different repos depending on how it was configured. The fix mirrors the existing file-origin pattern: pull `decodeURIComponent` on `remoteUrl.pathname` before stripping the `.git` suffix and joining with the host. One production-line change. Add a vitest case in `repoCompileUtils.test.ts` that asserts the direct URL config produces a decoded `name` and `displayName`, plus the matching zoekt metadata fields. This mirrors the existing test for the file-origin path (`'should decode URL-encoded characters in origin url pathname'`). Out of scope: malformed percent escapes like `Project%GGName`. The file-origin path also throws on these via the raw `decodeURIComponent` call, so this PR preserves the same behavior. A separate change could wrap the decode with a malformed-escape fallback if the maintainer wants to relax that. Validation: - `yarn workspace @sourcebot/backend test --run src/repoCompileUtils.test.ts` -> 12 passed (11 pre-existing + 1 new) - `yarn workspace @sourcebot/backend test --run` -> 262 passed (261 baseline + 1 new), 15 pre-existing failures unchanged - `yarn workspace @sourcebot/backend exec tsc --noEmit` -> 0 new errors introduced (all 11 pre-existing tsc errors are in the new BullMQ JobManager files added in #1427 and are unrelated to this PR) Fixes #1384
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review. WalkthroughGeneric Git URL compilation now decodes URL-encoded pathname characters before deriving repository names and display names. A regression test verifies decoded names and matching Zoekt metadata. ChangesGeneric Git URL repository naming
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change makes repository identifiers consistent for percent-encoded Git URLs without introducing an actionable merge-blocking risk; it is merge-ready after normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
compileGenericGitHostConfig_urlinpackages/backend/src/repoCompileUtils.tsderived the reponame/displayName/ zoekt metadata fromremoteUrl.pathnamewithout decoding percent-encoded characters. The file-origin counterpart (compileGenericGitHostConfig_file) already callsdecodeURIComponenton the origin URL pathname, so the same remote configured as a direct URL vs. discovered from a local repository origin ended up with two different identifiers.Concretely, a URL like
https://github.com/test/Project%20Name%20With%20Spaces.gitand a file config pointing at the same remote would derive:github.com/test/Project%20Name%20With%20Spacesgithub.com/test/Project Name With SpacesThat breaks search-index metadata (the value is written into
zoekt.name/zoekt.display-name/name/displayName) and makes the same repository look like two different repos depending on how it was configured.The fix mirrors the existing file-origin pattern: pull
decodeURIComponentonremoteUrl.pathnamebefore stripping the.gitsuffix and joining with the host. One production-line change.Validation
yarn workspace @sourcebot/backend test --run src/repoCompileUtils.test.ts→ 12 passed (11 pre-existing + 1 new)yarn workspace @sourcebot/backend test --run→ 262 passed (261 baseline + 1 new), 15 pre-existing failures unchangedyarn workspace @sourcebot/backend exec tsc --noEmit→ 0 new errors introduced (all 11 pre-existing tsc errors are in the new BullMQ JobManager files added in feat(backend): add BullMQ JobManager framework #1427 and are unrelated to this PR)Test plan
yarn workspace @sourcebot/backend test --run src/repoCompileUtils.test.ts(12 passed)yarn workspace @sourcebot/backend test --run(262 passed; same 15 pre-existing failures asupstream/main)yarn workspace @sourcebot/backend exec tsc --noEmit(0 new errors)Out of scope
Malformed percent escapes like
Project%GGName. The file-origin path also throws on these via the rawdecodeURIComponentcall, so this PR preserves the same behavior. A separate change could wrap the decode with a malformed-escape fallback if the maintainer wants to relax that.Fixes #1384
Note
Low Risk
Single-path naming change in repo compile utilities with a focused unit test; no auth, security, or data migration impact.
Overview
Direct HTTPS generic git connections now decode percent-encoded path segments (e.g.
%20→ space) when building reponame,displayName, and zoekt metadata, matching the existing file-origin compile path.That removes a mismatch where the same remote configured as a URL vs. discovered from a local clone could get two identifiers (encoded vs. decoded), which broke search-index consistency.
A regression test covers URL configs with spaces in the repo path and asserts
zoekt.name/zoekt.display-namealign with the decoded name.Reviewed by Cursor Bugbot for commit 91ffdbc. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit