Skip to content

Fix/azure devops url parsing#2269

Open
Tankatronic wants to merge 3 commits intobmad-code-org:mainfrom
Tankatronic:fix/azure-devops-url-parsing
Open

Fix/azure devops url parsing#2269
Tankatronic wants to merge 3 commits intobmad-code-org:mainfrom
Tankatronic:fix/azure-devops-url-parsing

Conversation

@Tankatronic
Copy link
Copy Markdown

What

Added Azure DevOps URL support to CustomModuleManager.parseSource(), fixing clone failures for dev.azure.com and legacy visualstudio.com _git URLs.

Why

The HTTPS regex only handles 2-segment paths owner/repo, but Azure DevOps uses org/project/_git/repo. The _git/repo portion was silently discarded, causing git clone to target the wrong URL.
Fixes #2268

How

Added dedicated Azure DevOps URL matching before the generic HTTPS regex in parseSource(), handling both modern dev.azure.com/{org}/{project}/_git/{repo} and legacy {org}.visualstudio.com/{project}/_git/{repo} formats
Correctly reconstructs cloneUrl, cacheKey, and displayName for both URL structures
Added test/test-azure-devops-url-parsing.js with 24 tests covering both formats, .git suffix stripping, subdir extraction, and regression checks for existing GitHub/GitLab/SSH parsing

Testing

Ran node test/test-azure-devops-url-parsing.js — 24 passed, 0 failed. Existing test-workflow-path-regex.js still passes (5/5).

Added support for Azure DevOps URL parsing, including both modern and legacy formats, to extract relevant repository information.
This test file verifies the functionality of the CustomModuleManager's parseSource method for Azure DevOps Git URLs, including both dev.azure.com and legacy visualstudio.com formats. It includes various assertions to check the validity and expected outputs for different URL formats.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

Added test coverage for Azure DevOps Git URL parsing and extended parseSource() in the custom module manager to handle both modern (dev.azure.com) and legacy (visualstudio.com) Azure DevOps repository URL formats, with proper cloneUrl normalization and subdirectory extraction.

Changes

Cohort / File(s) Summary
Test Coverage
test/test-azure-devops-url-parsing.js
New test script validating Azure DevOps URL parsing for both modern and legacy hosts, including cloneUrl normalization, subdir extraction, and regression checks for non-Azure sources (GitHub HTTPS and SSH URLs).
Azure DevOps URL Parsing
tools/installer/modules/custom-module-manager.js
Extended parseSource() to recognize and normalize Azure DevOps URLs in formats https://dev.azure.com/{org}/{project}/_git/{repo} and https://{org}.visualstudio.com/{project}/_git/{repo}, constructing proper cloneUrl, displayName, and cacheKey with optional subdirectory extraction.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately captures the main change: fixing Azure DevOps URL parsing in the parseSource method.
Description check ✅ Passed The description clearly explains the problem (HTTPS regex handling only 2-segment paths), the solution (dedicated Azure DevOps URL matching), and verification (24 passing tests).
Linked Issues check ✅ Passed All objectives from issue #2268 are addressed: Azure DevOps URLs (modern and legacy) are detected and parsed correctly, _git segments are preserved in cloneUrl, and compatibility with existing parsers is maintained.
Out of Scope Changes check ✅ Passed All changes directly support the stated objective of fixing Azure DevOps URL parsing with comprehensive test coverage and no unrelated modifications.

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

✨ 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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/test-azure-devops-url-parsing.js (1)

66-89: Add regression tests for ?path= URLs and dotted repo names

Please add Azure cases like ...?path=/foo/bar and repo names such as my.repo for both host formats. These are common inputs and should be locked in by tests.

Also applies to: 95-110

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/test-azure-devops-url-parsing.js` around lines 66 - 89, Add regression
tests in test/test-azure-devops-url-parsing.js that cover Azure URLs with
?path=/foo/bar query parameters and repository names containing dots (e.g.,
my.repo) for both Azure host formats exercised elsewhere in this file; for each
new case call manager.parseSource(...) and assert result.isValid === true,
assert result.cloneUrl is the repository clone URL with any .git suffix and any
path/query stripped, and assert result.subdir === 'foo/bar' (or the
corresponding path) to ensure query-path parsing and dotted repo names are
handled correctly by parseSource.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tools/installer/modules/custom-module-manager.js`:
- Around line 79-85: The ADO URL regex used for adoModernMatch and
adoLegacyMatch currently disallows dots in repo names and only captures
slash-based remainders; update the patterns used where adoModernMatch and
adoLegacyMatch are created so the repo capture uses a more permissive token
(allowing dots — e.g., replace `([^/.]+?)` with a pattern that permits dots) and
extend the final capture group to include query strings and `?path=` style
params (capture `(?:[/?].*)?` or equivalent) so links like `...?path=/src` are
accepted; also apply the same change to the later parsing logic referenced
around the block handling lines ~102-108 to ensure both slash remainder and
query-based remainders are handled consistently.

---

Nitpick comments:
In `@test/test-azure-devops-url-parsing.js`:
- Around line 66-89: Add regression tests in
test/test-azure-devops-url-parsing.js that cover Azure URLs with ?path=/foo/bar
query parameters and repository names containing dots (e.g., my.repo) for both
Azure host formats exercised elsewhere in this file; for each new case call
manager.parseSource(...) and assert result.isValid === true, assert
result.cloneUrl is the repository clone URL with any .git suffix and any
path/query stripped, and assert result.subdir === 'foo/bar' (or the
corresponding path) to ensure query-path parsing and dotted repo names are
handled correctly by parseSource.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d547ae65-b0ff-41dd-9689-6ae2e747520a

📥 Commits

Reviewing files that changed from the base of the PR and between 6b964ac and ba7b617.

📒 Files selected for processing (2)
  • test/test-azure-devops-url-parsing.js
  • tools/installer/modules/custom-module-manager.js

Comment on lines +79 to +85
/^https?:\/\/(dev\.azure\.com)\/([^/]+)\/([^/]+)\/_git\/([^/.]+?)(?:\.git)?(\/.*)?$/,
);
const adoLegacyMatch =
!adoModernMatch &&
trimmed.match(
/^https?:\/\/([^/]+\.visualstudio\.com)\/([^/]+)\/_git\/([^/.]+?)(?:\.git)?(\/.*)?$/,
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Azure DevOps regex currently rejects valid repo URLs and misses ?path= subdirs

Line 79 and Line 84 use ([^/.]+?), which rejects repo names containing dots, and Line 102-108 only handles slash-based remainder, not common Azure DevOps query links like ...?path=/src. This can still fail valid user inputs.

Proposed fix
-    const adoModernMatch = trimmed.match(
-      /^https?:\/\/(dev\.azure\.com)\/([^/]+)\/([^/]+)\/_git\/([^/.]+?)(?:\.git)?(\/.*)?$/,
-    );
+    const adoModernMatch = trimmed.match(
+      /^https?:\/\/(dev\.azure\.com)\/([^/]+)\/([^/]+)\/_git\/([^/]+?)(?:\.git)?(?:\/([^?#]*))?(?:\?([^#]*))?$/,
+    );
     const adoLegacyMatch =
       !adoModernMatch &&
       trimmed.match(
-        /^https?:\/\/([^/]+\.visualstudio\.com)\/([^/]+)\/_git\/([^/.]+?)(?:\.git)?(\/.*)?$/,
+        /^https?:\/\/([^/]+\.visualstudio\.com)\/([^/]+)\/_git\/([^/]+?)(?:\.git)?(?:\/([^?#]*))?(?:\?([^#]*))?$/,
       );
@@
-      let host, org, project, repo, remainder;
+      let host, org, project, repo, remainderPath, query;
       if (adoModernMatch) {
-        [, host, org, project, repo, remainder] = adoModernMatch;
+        [, host, org, project, repo, remainderPath, query] = adoModernMatch;
       } else {
         // Legacy: org is in the hostname, path is /{project}/_git/{repo}
-        [, host, project, repo, remainder] = adoLegacyMatch;
+        [, host, project, repo, remainderPath, query] = adoLegacyMatch;
         org = null;
       }
@@
-      if (remainder) {
-        // Azure DevOps uses ?path=/subdir or /path/subdir patterns
-        const subdirMatch = remainder.match(/^\/(.+)$/);
-        if (subdirMatch) {
-          subdir = subdirMatch[1].replace(/\/$/, '');
-        }
+      if (remainderPath) {
+        subdir = remainderPath.replace(/\/$/, '');
+      } else if (query) {
+        const pathParam = new URLSearchParams(query).get('path');
+        if (pathParam) subdir = pathParam.replace(/^\/+|\/+$/g, '');
       }

Also applies to: 102-108

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/installer/modules/custom-module-manager.js` around lines 79 - 85, The
ADO URL regex used for adoModernMatch and adoLegacyMatch currently disallows
dots in repo names and only captures slash-based remainders; update the patterns
used where adoModernMatch and adoLegacyMatch are created so the repo capture
uses a more permissive token (allowing dots — e.g., replace `([^/.]+?)` with a
pattern that permits dots) and extend the final capture group to include query
strings and `?path=` style params (capture `(?:[/?].*)?` or equivalent) so links
like `...?path=/src` are accepted; also apply the same change to the later
parsing logic referenced around the block handling lines ~102-108 to ensure both
slash remainder and query-based remainders are handled consistently.

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.

[BUG] Custom module install fails for Azure DevOps HTTPS URLs — parseSource truncates _git path

1 participant