Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error pushing to github using 0.26.2 #2101

Open
SnoopyKun opened this issue Jun 7, 2024 · 4 comments
Open

Error pushing to github using 0.26.2 #2101

SnoopyKun opened this issue Jun 7, 2024 · 4 comments

Comments

@SnoopyKun
Copy link

I'm using 0.26.2 to push files to github, and it gives me request failed with status code 500, and I'm using personal access token of github for authentication.

following is how I create push option
return new PushOptions()
{
CredentialsProvider = CreateCredentialsProvider(),
OnPushStatusError = new PushStatusErrorHandler(error =>
{
throw new NonFastForwardException($"{error.Message} at {error.Reference}");
})
};

and following is how I create Credentials Provider:
return new CredentialsHandler((url, userNameFromUrl, types) =>
{
return new UsernamePasswordCredentials()
{
Username = credential.UserName,
Password = credential.Password ?? string.Empty,
};
});

can somebody help me to find out what's wrong

@ronymeyer
Copy link

Did it ever work for you? I have the same issue with version 0.30 with GitHub, issue started around 18 hours ago, without any code changes.
Pulling with the same credentials works.

@Jo64
Copy link

Jo64 commented Jun 8, 2024

Same problem here.
We use 0.27.2 with the Personal access token and have no code changes and now we also get the error message when pushing.
LibGit2Sharp.LibGit2SharpException: request failed with status code: 500.
An update to 0.30.0 throws the same error message

repository.Network.Push(mainBranch, new PushOptions()
{
	CredentialsProvider = new LibGit2Sharp.Handlers.CredentialsHandler(Credentials),
	OnPushStatusError = new LibGit2Sharp.Handlers.PushStatusErrorHandler(PushStatusError),
});

public LibGit2Sharp.Credentials Credentials(string url, string usernameFromUrl, LibGit2Sharp.SupportedCredentialTypes types)
{
	return new LibGit2Sharp.UsernamePasswordCredentials
	{
		Username = Token,
		Password = String.Empty
	};
}
public void PushStatusError(PushStatusError pushStatusErrors)
{
	System.Diagnostics.Debug.WriteLine($@"{nameof(PushStatusError)} Reference: {pushStatusErrors.Reference} Message: {pushStatusErrors.Message}");
	throw new Exception($"PushStatusError: {pushStatusErrors.Message}");
}
LibGit2Sharp.LibGit2SharpException
  HResult=0x80131500
  Message=request failed with status code: 500
  Source=LibGit2Sharp
  StackTrace:
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_remote_push(RemoteHandle remote, IEnumerable`1 refSpecs, GitPushOptions opts)
   at LibGit2Sharp.Network.Push(Remote remote, IEnumerable`1 pushRefSpecs, PushOptions pushOptions)
   at LibGit2Sharp.Network.Push(IEnumerable`1 branches, PushOptions pushOptions)

@rocklan
Copy link

rocklan commented Jun 11, 2024

I'm having the same issue. Using version 0.30.

@ronymeyer
Copy link

What fixed it for us is to specify the credentials only on pull but not on push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants