Repository navigation
Description
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
- Start AgentScope Service Control Plane with Git installed and working Git repository credentials.
- Navigate to
Resources → Workspaces → Skills → Manage sources. - Register a Git Marketplace pointing to a valid repository containing Skills.
- Open
Install from marketplaceand select the registered Git source. - Verify that the Skills are successfully listed.
- 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-onlyIt 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
- [handlers_marketplaces.go](https://github.com/agentscope-ai/agentscope-java/blob/v2.1.0-BETA1/agentscope-service/service-controlplane/internal/product/handlers_marketplaces.go)
- [handlers_workspace.go](https://github.com/agentscope-ai/agentscope-java/blob/v2.1.0-BETA1/agentscope-service/service-controlplane/internal/product/handlers_workspace.go)
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
- First Marketplace browse successfully clones the repository.
- Subsequent browse reuses the existing repository and refreshes it.
- Installing a Skill after browsing succeeds without attempting another clone.
- Updating the remote repository allows the existing cache to be refreshed.
- 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
logicwu0 commentedon Nov 10, 2026
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.
fix(service): reuse existing Git marketplace clones (agentscope-ai#4093)