[Bug] Projman plugin: repo auto-detection and org validation issues #64

Closed
opened 2026-01-21 20:02:28 +00:00 by lmiranda · 1 comment
Owner

Summary

During diagnostic and label sync operations on personal-projects/personal-portfolio, several issues were identified with the projman Gitea MCP tools.

Issues Identified

1. Repository Auto-Detection Not Working

Expected: MCP tools should auto-detect the repository from the git remote when repo parameter is omitted.

Actual: All calls fail with:

Error: Use 'owner/repo' format (e.g. 'org/repo-name')

Impact: Every MCP call requires explicit repo parameter, which is verbose and error-prone.

Suggestion: Parse the git remote origin URL to extract owner/repo:

git remote get-url origin
# ssh://git@hotserv.tailc9b278.ts.net:2222/personal-projects/personal-portfolio.git
# -> personal-projects/personal-portfolio

2. validate_repo_org Returns False for Valid Organization

Expected: validate_repo_org should return true for repos under organizations.

Actual: Returns {"is_organization": false} for personal-projects/personal-portfolio.

Possible causes:

  • personal-projects may be configured as a user account in Gitea rather than a true organization
  • API endpoint may be checking the wrong attribute
  • Gitea API behavior difference between user-owned and org-owned repos

To investigate: Check Gitea admin to verify personal-projects entity type.

3. Organization Labels Always Empty

Expected: get_labels should return organization-level labels in the organization array.

Actual: Always returns:

{"organization": [], "repository": [...], "total_count": N}

Likely related to: Issue #2 - if the API doesn't recognize the owner as an organization, it won't fetch org-level labels.

Environment

  • Repository tested: personal-projects/personal-portfolio
  • Gitea host: gitea.hotserv.cloud
  • Git remote: ssh://git@hotserv.tailc9b278.ts.net:2222/personal-projects/personal-portfolio.git

Suggested Improvements

  1. Add repo auto-detection - Parse git remote URL when repo parameter is omitted
  2. Debug org validation - Verify the Gitea API endpoint and response handling
  3. Graceful fallback - When org validation fails, continue with repo-level operations and log a warning
  4. Better error messages - Include the detected/expected repo path in error messages

Labels

Type: Bug, Priority: Medium, Complexity: Medium

## Summary During diagnostic and label sync operations on `personal-projects/personal-portfolio`, several issues were identified with the projman Gitea MCP tools. ## Issues Identified ### 1. Repository Auto-Detection Not Working **Expected:** MCP tools should auto-detect the repository from the git remote when `repo` parameter is omitted. **Actual:** All calls fail with: ``` Error: Use 'owner/repo' format (e.g. 'org/repo-name') ``` **Impact:** Every MCP call requires explicit `repo` parameter, which is verbose and error-prone. **Suggestion:** Parse the git remote `origin` URL to extract `owner/repo`: ```bash git remote get-url origin # ssh://git@hotserv.tailc9b278.ts.net:2222/personal-projects/personal-portfolio.git # -> personal-projects/personal-portfolio ``` ### 2. `validate_repo_org` Returns False for Valid Organization **Expected:** `validate_repo_org` should return `true` for repos under organizations. **Actual:** Returns `{"is_organization": false}` for `personal-projects/personal-portfolio`. **Possible causes:** - `personal-projects` may be configured as a user account in Gitea rather than a true organization - API endpoint may be checking the wrong attribute - Gitea API behavior difference between user-owned and org-owned repos **To investigate:** Check Gitea admin to verify `personal-projects` entity type. ### 3. Organization Labels Always Empty **Expected:** `get_labels` should return organization-level labels in the `organization` array. **Actual:** Always returns: ```json {"organization": [], "repository": [...], "total_count": N} ``` **Likely related to:** Issue #2 - if the API doesn't recognize the owner as an organization, it won't fetch org-level labels. ## Environment - **Repository tested:** `personal-projects/personal-portfolio` - **Gitea host:** `gitea.hotserv.cloud` - **Git remote:** `ssh://git@hotserv.tailc9b278.ts.net:2222/personal-projects/personal-portfolio.git` ## Suggested Improvements 1. **Add repo auto-detection** - Parse git remote URL when `repo` parameter is omitted 2. **Debug org validation** - Verify the Gitea API endpoint and response handling 3. **Graceful fallback** - When org validation fails, continue with repo-level operations and log a warning 4. **Better error messages** - Include the detected/expected repo path in error messages ## Labels `Type: Bug`, `Priority: Medium`, `Complexity: Medium`
Author
Owner

Fixes Applied

Issue 1: Repository Auto-Detection

File: mcp-servers/gitea/mcp_server/config.py

Added _detect_repo_from_git() and _parse_git_url() methods that:

  • Run git remote get-url origin to get the remote URL
  • Parse various URL formats:
    • SSH: ssh://git@host:port/owner/repo.git
    • SSH short: git@host:owner/repo.git
    • HTTPS/HTTP: https://host/owner/repo.git
  • Auto-detect repo when GITEA_REPO env var is not set

Issue 2: Organization Validation

File: mcp-servers/gitea/mcp_server/gitea_client.py

Changed is_org_repo() to use /orgs/{owner} endpoint instead of relying on owner.type field (which was returning null in Gitea API):

  • Added _is_organization(owner) method
  • Returns True if /orgs/{owner} returns 200, False if 404
  • This reliably detects organizations regardless of Gitea version

Issue 3: Organization Labels

Fixed automatically by Issue 2 fix - now correctly fetches org-level labels for organization-owned repos.

Tests Added

  • test_parse_git_url_ssh_format
  • test_parse_git_url_ssh_short_format
  • test_parse_git_url_https_format
  • test_parse_git_url_http_format
  • test_parse_git_url_without_git_suffix
  • test_parse_git_url_invalid_format
  • test_is_organization_true
  • test_is_organization_false
  • test_is_org_repo_uses_orgs_endpoint

All 11 new tests passing.

## Fixes Applied ### Issue 1: Repository Auto-Detection ✅ **File:** `mcp-servers/gitea/mcp_server/config.py` Added `_detect_repo_from_git()` and `_parse_git_url()` methods that: - Run `git remote get-url origin` to get the remote URL - Parse various URL formats: - SSH: `ssh://git@host:port/owner/repo.git` - SSH short: `git@host:owner/repo.git` - HTTPS/HTTP: `https://host/owner/repo.git` - Auto-detect repo when `GITEA_REPO` env var is not set ### Issue 2: Organization Validation ✅ **File:** `mcp-servers/gitea/mcp_server/gitea_client.py` Changed `is_org_repo()` to use `/orgs/{owner}` endpoint instead of relying on `owner.type` field (which was returning `null` in Gitea API): - Added `_is_organization(owner)` method - Returns `True` if `/orgs/{owner}` returns 200, `False` if 404 - This reliably detects organizations regardless of Gitea version ### Issue 3: Organization Labels ✅ Fixed automatically by Issue 2 fix - now correctly fetches org-level labels for organization-owned repos. ### Tests Added - `test_parse_git_url_ssh_format` - `test_parse_git_url_ssh_short_format` - `test_parse_git_url_https_format` - `test_parse_git_url_http_format` - `test_parse_git_url_without_git_suffix` - `test_parse_git_url_invalid_format` - `test_is_organization_true` - `test_is_organization_false` - `test_is_org_repo_uses_orgs_endpoint` **All 11 new tests passing.**
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: personal-projects/leo-claude-mktplace#64