[Bug] Projman diagnostic failure: get_labels 404 for user-owned repos #61

Closed
opened 2026-01-21 19:29:19 +00:00 by lmiranda · 1 comment
Owner

Summary

The get_labels MCP tool fails with a 404 error when the repository owner is a user account rather than an organization.

Diagnostic Context

Repository tested: lmiranda/personal-portfolio
Host: gitea.hotserv.cloud

Failed Test

Tool Error
get_labels 404 Client Error: Not Found for url: https://gitea.hotserv.cloud/api/v1/orgs/lmiranda/labels

Root Cause

The tool attempts to fetch organization-level labels from /api/v1/orgs/{owner}/labels, but lmiranda is a user account, not an organization. Gitea's org labels endpoint returns 404 for user accounts.

Expected Behavior

The tool should:

  1. First check if the owner is an org or user
  2. If org: fetch org labels + repo labels
  3. If user: fetch only repo-level labels from /api/v1/repos/{owner}/{repo}/labels

Passing Tests (for reference)

All other diagnostic tests passed:

  • list_issues
  • list_milestones
  • list_wiki_pages
  • search_lessons
  • get_branch_protection

Labels

  • Type: Bug
  • Source: Internal
## Summary The `get_labels` MCP tool fails with a 404 error when the repository owner is a **user account** rather than an **organization**. ## Diagnostic Context **Repository tested**: `lmiranda/personal-portfolio` **Host**: `gitea.hotserv.cloud` ## Failed Test | Tool | Error | |------|-------| | `get_labels` | `404 Client Error: Not Found for url: https://gitea.hotserv.cloud/api/v1/orgs/lmiranda/labels` | ## Root Cause The tool attempts to fetch organization-level labels from `/api/v1/orgs/{owner}/labels`, but `lmiranda` is a **user account**, not an organization. Gitea's org labels endpoint returns 404 for user accounts. ## Expected Behavior The tool should: 1. First check if the owner is an org or user 2. If org: fetch org labels + repo labels 3. If user: fetch only repo-level labels from `/api/v1/repos/{owner}/{repo}/labels` ## Passing Tests (for reference) All other diagnostic tests passed: - `list_issues` ✓ - `list_milestones` ✓ - `list_wiki_pages` ✓ - `search_lessons` ✓ - `get_branch_protection` ✓ ## Labels - Type: Bug - Source: Internal
Author
Owner

Fix Applied

Changes made:

  1. mcp-servers/gitea/mcp_server/tools/labels.py

    • Modified get_labels() to check if repo owner is org or user via is_org_repo()
    • For user-owned repos: skips org label fetch (returns empty organization array)
    • For org-owned repos: fetches both org and repo labels (existing behavior)
  2. mcp-servers/gitea/mcp_server/gitea_client.py

    • Modified _resolve_label_ids() with same logic
    • Only fetches org labels when resolving label IDs if repo is org-owned
  3. mcp-servers/gitea/tests/test_labels.py

    • Added test_get_labels_org_owned_repo() - verifies org labels are fetched
    • Added test_get_labels_user_owned_repo() - verifies org labels are skipped
    • Fixed existing fixture to use owner/repo format

Test Results: 15/15 tests passing

The fix uses the existing is_org_repo() method which queries /api/v1/repos/{owner}/{repo} and checks owner.type to determine if the owner is an organization or user.

## Fix Applied **Changes made:** 1. **`mcp-servers/gitea/mcp_server/tools/labels.py`** - Modified `get_labels()` to check if repo owner is org or user via `is_org_repo()` - For user-owned repos: skips org label fetch (returns empty `organization` array) - For org-owned repos: fetches both org and repo labels (existing behavior) 2. **`mcp-servers/gitea/mcp_server/gitea_client.py`** - Modified `_resolve_label_ids()` with same logic - Only fetches org labels when resolving label IDs if repo is org-owned 3. **`mcp-servers/gitea/tests/test_labels.py`** - Added `test_get_labels_org_owned_repo()` - verifies org labels are fetched - Added `test_get_labels_user_owned_repo()` - verifies org labels are skipped - Fixed existing fixture to use `owner/repo` format **Test Results:** 15/15 tests passing The fix uses the existing `is_org_repo()` method which queries `/api/v1/repos/{owner}/{repo}` and checks `owner.type` to determine if the owner is an organization or user.
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#61