Skip to content

fix(git): classify HTTP errors from explicit status diagnostics - #5366

Merged
arturcic merged 5 commits into
GitTools:mainfrom
arturcic:codex/fix-git-http-status-classification
Oct 16, 2026
Merged

arturcic merged 5 commits into
GitTools:mainfrom
arturcic:codex/fix-git-http-status-classification

Conversation

@arturcic

@arturcic arturcic commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Description

Git network failures are currently classified by searching all stderr for 401, 403 and 404. A missing repository at http://127.0.0.1:40123/... is consequently reported as an authentication failure, and URL/path digits can override genuine HTTP diagnostics or unrelated connection errors.

Recognize status codes in Git's explicit The requested URL returned error: <status> diagnostic instead. Preserve the existing authentication/repository-not-found phrases and the original error for unrelated failures. Regression tests cover localhost ports, URL/path digits, actual HTTP errors, multiline RPC diagnostics with CRLF, longer numbers and local checkout failures.

The algorithm documentation review records are refreshed after reviewing all seven affected sections: this failure-only change leaves successful repository operations and version-calculation rules unchanged.

Related Issue

Resolves #5365. Also addresses the intermittent CloneOfMissingHttpRepositoryMapsGitsNotFoundPhrasing failure observed in #5207; the faulty classifier is already present on main.

How Has This Been Tested?

Latest head 16e9fcfb1 implements the failing executor stub explicitly through IGitCliExecutor, preserving both required parameters and the same deterministic result while addressing the two S1172 warnings. All 30 GitCliMutatorTests cases passed on each backend (0 failed/skipped), formatting and whitespace checks passed, and CodeRabbit review of the published change completed with 0 findings. Fresh GitHub CI/Sonar analysis is pending; the previous full-suite and review evidence below was obtained on pre-rebase head 8b27b0501. The fix was rebased onto 7f02b33eb with unchanged patch equivalence.

Using .NET SDK 10.0.402, Release/net10.0 on macOS arm64:

  • Before the production fix, 10 deterministic regression cases failed.
  • Full GitVersion.Core.Tests suite with GITVERSION_GIT_BACKEND=managed: 36,489 passed, 0 failed, 0 skipped.
  • Same build with GITVERSION_GIT_BACKEND=libgit2: 36,489 passed, 0 failed, 0 skipped.
  • Both JUnit reports parsed successfully with matching testcase method/count inventories, including 30 GitCliMutatorTests cases per backend.
  • dotnet format src/GitVersion.slnx --no-restore --verify-no-changes --include src/GitVersion.Git.Managed/CommandLine/GitCliMutator.cs src/GitVersion.Core.Tests/Core/GitCliMutatorTests.cs passed.
  • npm run test:algorithm-docs: 13 passed; npm run check:algorithm-docs verified all seven review records.
  • git diff --check passed.
  • CodeRabbit review of the published commit (--committed --base origin/main) completed with 0 findings across all three changed files.

Core-suite commands (JUnit reporting enabled for both runs):

GITVERSION_GIT_BACKEND=managed dotnet test --project src/GitVersion.Core.Tests/GitVersion.Core.Tests.csproj --configuration Release --report-spekt-junit --report-spekt-junit-filename results.xml --results-directory /tmp/git-http-status-core-managed
GITVERSION_GIT_BACKEND=libgit2 dotnet test --project src/GitVersion.Core.Tests/GitVersion.Core.Tests.csproj --configuration Release --no-build --report-spekt-junit --report-spekt-junit-filename results.xml --results-directory /tmp/git-http-status-core-libgit2

Checklist

  • Code follows the project's style.
  • Reviewed affected algorithm sections and their review records.
  • Added regression tests.
  • New and existing Core tests passed on both backends.

Created by Codex on behalf of @arturcic.

Summary by CodeRabbit

  • Bug Fixes
    • Git clone failures now identify authentication and repository-not-found errors from Git’s HTTP diagnostics, including diagnostics spanning multiple lines.
    • Numbers in URLs, ports, and file paths no longer cause misleading HTTP error messages; longer status-like numbers remain generic failures.
    • Checkout failures and unrecognized errors continue to use generic command-failure handling. Recognized Git error messages retain their existing handling.

Copilot AI balanced review requested due to automatic review settings October 15, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f4552b21-b437-4442-9bfc-0e0c049a6053
📥 Commits

Reviewing files that changed from the base of the PR and between 079f94e and 3b0543f.

📒 Files selected for processing: 1
  • docs/version-calculation-map.json
🚧 Files skipped from review as they are similar to previous changes: 1
  • docs/version-calculation-map.json

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

GitCliMutator now classifies HTTP errors from explicit Git diagnostics for failed network operations, rather than matching status-code digits anywhere in stderr. Regression tests cover valid statuses and unrelated numeric matches. The version-calculation review records now describe this change.

Changes: Git HTTP error classification

Layer / File(s) Summary
Classify HTTP errors from Git diagnostics
src/GitVersion.Git.Managed/CommandLine/GitCliMutator.cs
For failed network operations, HTTP status mapping now uses Git’s requested-URL diagnostic. Existing authentication and repository-not-found mappings remain.
Regression coverage and review records
src/GitVersion.Core.Tests/Core/GitCliMutatorTests.cs, docs/version-calculation-map.json
Tests check supported HTTP statuses, multiline diagnostics, unrelated status-like digits in URLs and paths, recognized error phrases, and checkout failures. Seven review records now describe the classification change.

Priority: ⬇️ Low

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

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 3b054

The reported HTTP error misclassification is addressed, with regression coverage for the identified cases. No actionable merge-blocking risk remains after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 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 the main change: classifying Git HTTP errors from explicit status diagnostics.
Linked Issues check Passed The changes satisfy the coding requirements in #5365. ThrowOnFailure reads 401, 403, and 404 only from Git's explicit The requested URL returned error: diagnostic during network operations. It pre…
Out of Scope Changes check Passed The changes remain within #5365. The production changes centralize the required Git diagnostic patterns and apply them only to network operations. The tests verify the required classification behavior…
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@arturcic
arturcic force-pushed the codex/fix-git-http-status-classification branch from 8b27b05 to c6f3840 Compare October 15, 2026 18:35
Comment thread src/GitVersion.Git.Managed/CommandLine/GitCliMutator.cs Outdated
@sonarqubecloud

Copy link
Copy Markdown

Copy link
Copy Markdown
Member Author

@coderabbitai resume

Codex, responding on behalf of @arturcic: please resume automated reviews for this PR.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

@arturcic I will resume automated reviews for this PR.

✅ Action performed

Reviews resumed and review finished.

@arturcic
arturcic merged commit da24c9e into GitTools:main Oct 16, 2026
41 checks passed
@arturcic
arturcic deleted the codex/fix-git-http-status-classification branch October 16, 2026 05:28
@mergify

mergify Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Thank you @arturcic for your contribution!

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] Git CLI HTTP errors misclassified when URLs or paths contain status-code digits

2 participants