Skip to content

[Bug]: Git Skill Marketplace fails to install skills due to incorrect .git directory detection #4092

Closed

Description

@AlexRITIAN

Description

The Git Skill Marketplace in AgentScope Service Control Plane fails to install skills after successfully cloning and browsing a Git repository.

The issue is caused by incorrect detection of the local Git repository cache. The implementation uses fileExists() to check whether the .git directory exists, but this function explicitly returns false for directories.

As a result, the Control Plane attempts to clone the same repository again into an existing, non-empty directory.

Environment

  • AgentScope Service Version: 2.1.0-BETA1
  • Deployment: Docker
  • Component: Service Control Plane
  • Marketplace Type: Git
  • Git Repository: Private GitLab repository
  • Git Executable: Installed in a custom Control Plane image

Steps to Reproduce

  1. Start AgentScope Service Control Plane with Git installed and working Git repository credentials.
  2. Navigate to Resources → Workspaces → Skills → Manage sources.
  3. Register a Git Marketplace pointing to a valid repository containing Skills.
  4. Open Install from marketplace and select the registered Git source.
  5. Verify that the Skills are successfully listed.
  6. Click Install on any listed Skill.

Actual Behavior

The installation fails with the following error:

marketplace clone failed; check source access and branch: exit status 128

The repository was previously cloned successfully, as the Skill listing was populated.

Expected Behavior

The Control Plane should detect the existing local Git repository cache and execute:

git -C <cache-directory> pull --ff-only

It should then read the selected Skill files and install them into the Workspace.

It should not attempt to clone the repository again when a valid local Git cache already exists.

Root Cause Analysis

In handlers_marketplaces.go, the ensureGitMarketplaceClone() function checks for an existing repository using:

if fileExists(filepath.Join(cache, ".git")) {
    cmd := exec.CommandContext(ctx, "git", "-C", cache, "pull", "--ff-only")
    // ...
}

However, fileExists() is implemented in handlers_workspace.go as:

func fileExists(p string) bool {
    st, err := os.Stat(p)
    return err == nil && !st.IsDir()
}

Since .git is normally a directory in a cloned repository, fileExists(cache/.git) always returns false for a standard Git clone.

This causes ensureGitMarketplaceClone() to repeatedly execute git clone instead of git pull.

When the destination directory already exists and is not empty, Git exits with status 128.

Relevant Source Files

Suggested Fix

Replace the fileExists() check with a directory-aware existence check.

For example:

- if fileExists(filepath.Join(cache, ".git")) {
+ if _, err := os.Stat(filepath.Join(cache, ".git")); err == nil {
      cmd := exec.CommandContext(ctx, "git", "-C", cache, "pull", "--ff-only")

This is the minimal fix. A more robust implementation could also validate that the cache is a usable Git repository before attempting to pull.

I would recommend avoiding changes to the shared fileExists() helper, as other callers may rely on its current file-only semantics.

Additional Improvement

Currently, Git commands are executed using cmd.Run(), which does not include Git's stderr in the returned error.

This makes diagnosing Git failures difficult, as users only see generic messages such as:

exit status 128

Consider capturing Git stderr with CombinedOutput() and including a sanitized version in the error response or server logs.

Suggested Regression Tests

  1. First Marketplace browse successfully clones the repository.
  2. Subsequent browse reuses the existing repository and refreshes it.
  3. Installing a Skill after browsing succeeds without attempting another clone.
  4. Updating the remote repository allows the existing cache to be refreshed.
  5. Invalid Git caches and authentication failures return actionable error messages.

Impact

This issue affects Git-based Skill Marketplace installations that reuse a repository cache.

It is not specific to private GitLab repositories and may also affect public GitHub repositories.

The same incorrect cache detection logic is also present in the current main branch.

Activity

  1. added
    bug
    on Nov 10, 2026
  2. logicwu0 commented on Nov 10, 2026

    @logicwu0
    Contributor

    I'd like to work on this. I'll first reproduce the cache reuse failure against current main, then add regression coverage using a local Git repository for initial cloning, repeated access, and refreshing remote updates. I'll keep the shared fileExists helper's file-only semantics unchanged.

  3. added a commit that references this issue on Nov 10, 2026
    874c9cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions