Skip to content

fix(backend): decode percent-encoded characters in generic git URL config - #1607

Closed
Harsh23Kashyap wants to merge 1 commit into
sourcebot-dev:mainfrom
Harsh23Kashyap:fix/generic-git-url-decode-pathname
Closed

fix(backend): decode percent-encoded characters in generic git URL config#1607
Harsh23Kashyap wants to merge 1 commit into
sourcebot-dev:mainfrom
Harsh23Kashyap:fix/generic-git-url-decode-pathname

Conversation

@Harsh23Kashyap

@Harsh23Kashyap Harsh23Kashyap commented Aug 18, 2026

Copy link
Copy Markdown

Summary

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.

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 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 as upstream/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 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.

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 repo name, 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-name align 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

  • Bug Fixes
    • Repository names and display names from direct Git URLs now correctly preserve URL-encoded characters.
    • Repository metadata now consistently reflects the decoded names used elsewhere in the application.

…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
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 44cd02e2-34e0-425e-b9d3-20514660abe1

📥 Commits

Reviewing files that changed from the base of the PR and between 6d1e610 and 91ffdbc.

📒 Files selected for processing (2)
  • packages/backend/src/repoCompileUtils.test.ts
  • packages/backend/src/repoCompileUtils.ts

Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review.


Walkthrough

Generic 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.

Changes

Generic Git URL repository naming

Layer / File(s) Summary
Decode repository pathnames
packages/backend/src/repoCompileUtils.ts, packages/backend/src/repoCompileUtils.test.ts
Generic Git URL pathnames are decoded before repository names are derived. Tests verify decoded repository names, display names, and Zoekt metadata.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 91ffd

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: brendan-kellam

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes decoding percent-encoded characters in generic Git URL configuration.
Linked Issues check ✅ Passed The changes decode URL-encoded Git path characters and update repository names, display names, and Zoekt metadata as required by issue #1384.
Out of Scope Changes check ✅ Passed The changes are limited to the required URL decoding logic and its regression test for issue #1384.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@Harsh23Kashyap Harsh23Kashyap closed this by deleting the head repository Aug 18, 2026
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.

Generic Git URL configs keep percent-encoded repo names

1 participant