Skip to content

clone doesn't work with aws codecommit credentials (reference delta not found) #5185

@bassofed

Description

@bassofed

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:

  1. Go to 'Stacks'
  2. Click to 'Add Stack'
  3. Set the name of the new stack (my_aws_stack)
  4. Click on 'git Repository'
  5. Set the url of the repository (https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my_aws_repo)
  6. Enable 'Authentication' switch
  7. Set Https user and Password
  8. Click on 'Deploy the stack'
  9. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions