-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Bug description
git clone returns "reference delta not found" when using an AWS codecommit repository with https credentials
Portainer Logs
2021/06/11 15:21:53 proxy error: http: read on closed response body,
2021/06/14 08:13:47 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 08:13:47 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 08:13:47 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 08:13:47 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 08:18:15 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 08:18:15 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 08:18:15 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 08:18:15 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 10:56:50 http error: Unable to clone git repository (err=reference delta not found) (code=500),
2021/06/14 12:08:05 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 12:08:06 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 12:08:06 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 12:08:06 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 12:08:06 http error: Invalid JWT token (err=Invalid JWT token) (code=401),
2021/06/14 12:24:56 http error: Unable to clone git repository (err=reference delta not found) (code=500),
Steps to reproduce the issue:
- Go to 'Stacks'
- Click to 'Add Stack'
- Set the name of the new stack (my_aws_stack)
- Click on 'git Repository'
- Set the url of the repository (https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my_aws_repo)
- Enable 'Authentication' switch
- Set Https user and Password
- Click on 'Deploy the stack'
- After few second the deploy fails due to 'reference delta not found' error
Technical details:
- Portainer version: 2.5.1
Additional context
I'm totally new to GO so I'm not able to deeply debug the code but, since the error involed git, I tried to look inside api/git/git.go
I was able to reproduce the error using this code
func main() {
fmt.Println("Hello, World!")
repourl := "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my_aws_repo"
gitOptions := git.CloneOptions{
URL: repourl,
// Depth: 1,
}
gitOptions.Auth = &githttp.BasicAuth{
Username: "my_https_aws_user",
Password: "my_https_aws_password",
}
_, err := git.PlainCloneContext(context.TODO(), "my_aws_repo", false, &gitOptions)
if err != nil {
fmt.Println(err)
}
}
output:
reference delta not found
If I change the 'gitOption' definition to:
gitOptions := git.CloneOptions{
URL: repourl,
Depth: 1,
}
(so I only uncommented the 'Depth' param)
The clone works.
I tried with a GitHub repository and the clone works with both implementations: with and without 'Depth' definition.
I see from the source code that a default '1' value for 'Depth' should be set by default but from the behaviour I can see it seems that it's not working