Skip to content

chore: categorize empty repo error [CM-1103]#4017

Merged
mbani01 merged 1 commit intomainfrom
chore/categorize_empty_repo_errors
Apr 13, 2026
Merged

chore: categorize empty repo error [CM-1103]#4017
mbani01 merged 1 commit intomainfrom
chore/categorize_empty_repo_errors

Conversation

@mbani01
Copy link
Copy Markdown
Contributor

@mbani01 mbani01 commented Apr 13, 2026

This pull request adds support for handling empty repositories in the git integration service. The main changes introduce a new error type for empty repositories, update the error code enumeration, and ensure that ambiguous HEAD errors are mapped to this new error. The most important changes are:

Error handling improvements:

  • Added a new error code EMPTY_REPO to the ErrorCode enum in enums.py, representing the case when a repository is empty (no branches or commits).
  • Introduced a new EmptyRepoError dataclass in errors.py to encapsulate the error message and code for empty repositories.
  • Updated the error mapping in utils.py so that ambiguous HEAD errors (which indicate an empty repository) now raise EmptyRepoError.
  • Added EmptyRepoError to the list of imported errors in utils.py to enable its use in error handling logic.

Note

Low Risk
Low risk: adds a new error code/exception and maps a specific git stderr pattern to it, only affecting how empty-repo failures are classified and reported.

Overview
Adds first-class classification for empty repositories in the git integration service.

Introduces ErrorCode.EMPTY_REPO and a corresponding EmptyRepoError, and updates shell error classification so git failures containing ambiguous argument 'HEAD' are surfaced as EmptyRepoError instead of a generic command failure.

Reviewed by Cursor Bugbot for commit 31f55dc. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
@mbani01 mbani01 self-assigned this Apr 13, 2026
Copilot AI review requested due to automatic review settings April 13, 2026 10:54
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@mbani01 mbani01 changed the title chore: categorize empty repo error chore: categorize empty repo error [CM-1103] Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@mbani01 mbani01 merged commit 0f0de60 into main Apr 13, 2026
22 checks passed
@mbani01 mbani01 deleted the chore/categorize_empty_repo_errors branch April 13, 2026 10:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a dedicated error classification for empty Git repositories to the git integration service so “ambiguous HEAD” failures can be surfaced with a specific error code.

Changes:

  • Added EMPTY_REPO to ErrorCode.
  • Introduced EmptyRepoError as a new CrowdGitError type.
  • Classified ambiguous HEAD stderr output to raise EmptyRepoError in shell error handling.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
services/apps/git_integration/src/crowdgit/services/utils.py Maps ambiguous HEAD stderr to the new EmptyRepoError.
services/apps/git_integration/src/crowdgit/errors.py Adds EmptyRepoError dataclass with standardized message/code.
services/apps/git_integration/src/crowdgit/enums.py Extends ErrorCode with EMPTY_REPO.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +187 to +190
(
{"ambiguous argument 'HEAD': unknown revision or path not in the working tree"},
EmptyRepoError,
),
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.

3 participants